#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
int tr[4*N],mod,t,q;
void pushup(int k){
tr[k]=(tr[k*2]*tr[k*2+1])%mod;
}
void update(int k,int l,int r,int x,int c){
if(l==r){
tr[k]=c;
return ;
}
int mid=(l+r)/2;
if(x<=mid){
update(k*2,l,mid,x,c);
}
else
{
update(k*2+1,mid+1,r,x,c);
}
pushup(k);
}
signed main(){
cin>>t;
while(t--){
cin>>q>>mod;
int opt,x;
for(int i=0;i<=400000;i++){
tr[i]=1;
}
for(int i=1;i<=q;++i){
cin>>opt>>x;
if(opt==1){
update(1,1,100000,i,x);
cout<<tr[1]<<endl;
}
else
{
update(1,1,100000,x,1);
cout<<tr[1]<<endl;
}
}
}
return 0;
}撒旦
这是 2026年8月14日 存档的第 15 版,不是当前版本。查看当前版本