#include #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define Yes cout << "Yes" << "\n" #define No cout << "No" << "\n" #define rtr0 return(0) #define all(x) x.begin(), x.end() using namespace std; //#include //using namespace atcoder; //using mint=static_modint<998244353>; //using mint=static_modint<1000000007>; ////using mint=modint; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using ll=long long; using l3=__int128; using ull=unsigned long long; using ld=long double; using P=pair; const ld PI=acos(-1); templatebool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} templatebool chmax(T&a,T b){if(a dx={1,0,-1,0}; const vector dy={0,1,0,-1}; const int inf=1001001001; const ll INF=1001001001001001001; ll mod=998244353; //1 5 7 11 //1 11 19 29 vector v1={1,5,7,11}; vector v2={1,11,19,29}; void solve(){ ll n,q;cin>>n>>q; unordered_set st; unordered_set s1,s2; rep(i,n){ ll x;cin>>x; st.insert(x); if(x%11==0)s1.insert(x); if(x%29==0)s2.insert(x); } unordered_set a1,a2; ll ans=0; for(auto x:s1){ ll y=x/11; if(st.count(y*7)&&st.count(y*5)&&st.count(y)){ ans++; a1.insert(y); } } for(auto x:s2){ ll y=x/29; if(st.count(y*19)&&st.count(y*11)&&st.count(y)){ ans++; a2.insert(y); } } rep(i,q){ ll t,x;cin>>t>>x; if(t==1){ st.insert(x); rep(i,4){ if(x%v1[i]!=0)continue; ll m=x/v1[i]; if(st.count(v1[(i+1)%4]*m)&&st.count(v1[(i+2)%4]*m)&&st.count(v1[(i+3)%4]*m)){ ans++; a1.insert(m); } } rep(i,4){ if(x%v2[i]!=0)continue; ll m=x/v2[i]; if(st.count(v2[(i+1)%4]*m)&&st.count(v2[(i+2)%4]*m)&&st.count(v2[(i+3)%4]*m)){ ans++; a2.insert(m); } } } else{ rep(i,4){ if(x%v1[i]!=0)continue; ll m=x/v1[i]; if(st.count(v1[(i+1)%4]*m)&&st.count(v1[(i+2)%4]*m)&&st.count(v1[(i+3)%4]*m)){ ans--; a1.erase(m); } } rep(i,4){ if(x%v2[i]!=0)continue; ll m=x/v2[i]; if(st.count(v2[(i+1)%4]*m)&&st.count(v2[(i+2)%4]*m)&&st.count(v2[(i+3)%4]*m)){ ans--; a2.erase(m); } } st.erase(x); } cout<>t; rep(i,t)solve(); }