#include using namespace std; typedef long long ll; typedef pair pii; typedef pair ppii; typedef pair pipi; typedef pair pll; typedef pair plpl; typedef tuple tl; ll mod=1000000007; ll mod2=998244353; ll inf=1000000000000000000; #define rep(i,m,n) for(int i=m;i=m;i--) ll lmax(ll a,ll b){ if(a pri; void priinit(ll n){ bool used[n+1]; fill(used,used+n+1,false); rep(i,2,n+1){ if(used[i]==false){ pri.push_back(i); for(ll j=i;j<=n;j+=i)used[j]=true; } } } vector prisep(ll n){ vector ret; rep(i,0,pri.size()){ while(n%pri[i]==0){ ret.push_back(pri[i]); n/=pri[i]; } } return ret; } ll par[200010]; ll par2[200010]; void init(ll n){ for(int i=0;i=n){ u=y; break; } } fill(bit,bit+u+10,0); } void add(ll n,ll x){ ll i=n; bit[i]+=x; while(i0){ ret+=bit[i]; i-=i&(-i); } return ret; } int main(){ ll n,q;cin>>n>>q; ll a[n];rep(i,0,n)cin>>a[i]; init(n+1); bitinit(n+1); rep(i,0,n)add(i+1,a[i]); ll k=0; rep(i,0,q){ ll c,x;cin>>c>>x; if(c==1){ unit(x,x+1); k=0; } if(c==2){ sepa(x,x+1); k=0; } if(c==3){ add(x,1); } if(c==4){ ll l; ll r; k++; if(k>=2){ l=roo2(x); r=roo(x); } else{ l=root2(x); r=root(x); } //cout<