#include using namespace std; using lol=long long int; #define endl "\n" const lol mod1=1e9+7,mod2=998244353,mod3=100000000000000003,hashpr=31; const lol inf=9e18+8; const double eps=1e-12; const double PI=acos(-1.0); const int N=1e5+5; #include // Common file #include // Including tree_order_statistics_node_update using namespace __gnu_pbds; using ordered_set_type=lol; typedef tree,rb_tree_tag,tree_order_statistics_node_update> ordered_set; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); pair exgcd(lol a,lol b){ if(b == 0){ return make_pair(1, 0); } auto [x1, y1] = exgcd(b, a % b); lol x = y1; lol y = x1 - y1 * (a / b); return make_pair(x, y); } struct LinearBasis{ static const int d = 65; lol mod; struct Vector{ lol mod; vector vec; Vector(lol v, lol m):mod(m){ vec.resize(d, 0); vector t; while(v){ t.push_back(v % mod); v /= mod; } for(int i=0;i<(int)t.size();i++){ vec[d-1-i] = t[i]; } } lol to_number(){ lol R = 0; for(int i=0;ivec[i] += other.vec[i] % mod; this->vec[i] %= mod; } return *this; } friend Vector operator+(Vector lhs, const Vector& rhs){ lhs += rhs; return lhs; } Vector& operator-=(const Vector& other){ for(int i=0;ivec[i] -= other.vec[i] % mod; this->vec[i] = (this->vec[i] + mod) % mod; } return *this; } friend Vector operator-(Vector lhs, const Vector& rhs){ lhs -= rhs; return lhs; } Vector& operator*=(const lol& scalar){ for(int i=0;ivec[i] *= scalar % mod; this->vec[i] %= mod; } return *this; } friend Vector operator*(Vector lhs, const lol& rhs){ lhs *= rhs; return lhs; } friend Vector operator*(const lol& rhs, Vector lhs){ lhs *= rhs; return lhs; } }; vector A; //this is the basis Vector vec(lol v){ return Vector(v, mod); } LinearBasis(lol m): mod(m){A.resize(d,vec(0));} void add(Vector V){ for(int i=0;i B) return -1; auto R = vec(0); for(int i=0;i>k>>q; auto L = LinearBasis(k); while(q--){ int t; lol x; cin>>t>>x; if(t==1){ L.add(L.vec(x)); }else if(t==2){ cout<>_; while(_--) { solve(); } return 0; }