#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()); int exgcd(int a, int b, int& x, int& y) { x = 1, y = 0; int x1 = 0, y1 = 1, a1 = a, b1 = b; while (b1) { int q = a1 / b1; tie(x, x1) = make_tuple(x1, x - q * x1); tie(y, y1) = make_tuple(y1, y - q * y1); tie(a1, b1) = make_tuple(b1, a1 - q * b1); } return a1; } struct LinearBasis{ static const int d = 61; int mod; struct Vector{ int mod; vector vec; Vector(int v, int 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]; } } int add(int a, int b){ return a+b>=mod?a+b-mod:a+b; } int sub(int a, int b){ return a>=b?a-b:a-b+mod; } lol to_number(){ lol R = 0; for(int i=0;ivec[i] = add(this->vec[i], other[i]); } 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] = sub(this->vec[i], other[i]); } 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] == 0) continue; this->vec[i] = (this->vec[i] * scalar) % 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(int v){ return Vector(v, mod); } LinearBasis(int 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; }