#include using namespace std; //#include //using namespace atcoder; /*---------macro---------*/ #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, s, n) for (int i = s; i < (int)(n); ++i) #define Clear(a) a = decltype(a)() #define all(a) begin(a),end(a) #define rall(a) rbegin(a),rend(a) #define bit(i,j) ((i>>j)&1) /*---------type/const---------*/ typedef long long ll; typedef unsigned long long ull; typedef string::const_iterator state; //構文解析 const ll big=1000000007; //const ll big=998244353; const double PI=acos(-1); const double EPS=1e-8;//適宜変える const int dx[4]={1,0,-1,0}; const int dy[4]={0,1,0,-1}; const char newl='\n'; struct{ constexpr operator int(){return int(1e9)+1;} constexpr operator ll(){return ll(1e18)+1;} constexpr auto operator-(){ struct{ constexpr operator int(){return -int(1e9)-1;} constexpr operator ll(){return -ll(1e18)-1;} }_ret; return _ret; } }inf; /*---------debug用関数---------*/ #ifdef LOGX #define _GLIBCXX_DEBUG #define dbg(x) cout << #x << ':',prt(x); template inline void prt(T a_); template inline void _prt(T a_); template inline void _prt(map a_); template inline void _prt(unordered_map a_); template inline void _prt(set a_); template inline void _prt(unordered_set a_); template inline void _prt(pair a_); template inline void _prt(vector &a_); template inline void _prt(vector> &a_); //_prtでは改行しない. inline void _prt(bool a_){if(a_)cout<<1;else cout<<0;} inline void _prt(int a_){if(a_>=(int)inf)cout << "inf";else if(a_<=-(int)inf)cout << "-inf";else cout << a_;} inline void _prt(long long a_){if(a_>=(ll)inf)cout << "INF";else if(a_<=-(ll)inf)cout << "-INF";else cout << a_;} #ifdef ATCODER_MODINT_HPP templateinline void _prt(static_modint x){cout << x.val();} templateinline void _prt(dynamic_modint x){cout << x.val();} #endif template inline void _prt(T a_){cout << a_;} template inline void _prt(map a_){cout<<'{';auto it=a_.begin();while(it!=a_.end()){_prt((*it).first);cout<<':';_prt((*(it++)).second);cout<<(it==a_.end() ? "":",");}cout<<'}';} template inline void _prt(unordered_map a_){cout<<'{';auto it=a_.begin();while(it!=a_.end()){_prt((*it).first);cout<<':';_prt((*(it++)).second);cout<<(it==a_.end() ? "":",");}cout<<'}';} template inline void _prt(set a_){cout<<'{';auto it=a_.begin();while(it!=a_.end()){_prt(*it++);cout<<(it==a_.end() ? "":",");}cout<<'}';} template inline void _prt(unordered_set a_){cout<<'{';auto it=a_.begin();while(it!=a_.end()){_prt(*it++);cout<<(it==a_.end() ? "":",");}cout<<'}';} template inline void _prt(pair a_){cout << '(';_prt(a_.first);cout << ',';_prt(a_.second);cout << ')';} template inline void _prt(vector &a_){cout<<'{';for(int i=0;i<(int)a_.size();i++){_prt(a_[i]);if(i+1<(int)a_.size())cout<<',';}cout<<'}';} template inline void _prt(vector> &a_){cout<<"{\n";for(int i=0;i<(int)a_.size();i++){_prt(a_[i]);if(i+1<(int)a_.size())cout<<",\n";else cout<<"\n}";}} template inline void prt(T a_){_prt(a_);cout<<'\n';} #else #define dbg(x) ; #define prt(x) ; #define _prt(x) ; #endif /*---------function---------*/ template T max(const T x,const U y){if(x>y)return x;else return y;} template T min(const T x,const U y){if(x T max(const vector &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;} template T min(const vector &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;} template bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;} template bool chmax(T &a,const U b){if(a T expm(T x,U y,const ll mod=big){ T res=1; while(y){ if(y&1)(res*=x)%=mod; (x*=x)%=mod; y>>=1; } return res; } template T exp(T x,U y){ T res=1; while(y){ if(y&1)res*=x; x*=x; y>>=1; } return res; } const int MAX_COL=51;//適宜. struct bitMatrix{ int h,w; vector> val; bitMatrix(int m=1,int n=1):h(m),w(n){ val.resize(m); } inline bitset& operator[](const int i){return val[i];} }; int bit_Gauss_Jordan(bitMatrix &a,bool is_ex=false){ int rank=0; for(int col=0;col b,vector &res){ int m=A.h; int n=A.w; bitMatrix M(m,n+1); for(int i=0;i> N >> M; bitMatrix B(M,N); vector Y(M); for(int i=0;i> A; for(int j=0;j> b; B[i][b-1]=1; } cin >> Y[i]; } bool ok=true; vector ans(N); vector res; vector b(M); for(int i=0;i<30;i++){ for(int j=0;j>i)&1); int rank=bit_linear_equation(B,b,res); if(rank==-1){ ok=false; break; } dbg(res); for(int j=0;j