#include<bits/stdc++.h>
#define lp p<<1
#define rp p<<1|1
#define ll long long
using namespace std;
const int N=1e6+10;
ll t,q,m,op,m1,pos;
struct tree{
ll l,r,ans;
}tr[N*4];
void pushup(int p){
tr[p].ans=(1ll*tr[lp].ans*tr[rp].ans)%m;
}
void build(int l,int r,int p){
tr[p]={l,r,1};
if(l==r){
return;
}
int m=l+r>>1;
build(l,m,lp);
build(m+1,r,rp);
pushup(p);
}
void change(int x,int k,int p){
if(tr[p].l==x&&tr[p].r==x){
tr[p].ans=k;
return ;
}
int m=(tr[p].l+tr[p].r)>>1;
if(x<=m){
change(x,k,lp);
}
else{
change(x,k,rp);
}
pushup(p);
}
int main(){
cin>>t;
for(int i=1;i<=t;t++){
cin>>q>>m;
build(1,q,1);
for(int j=1;j<=q;j++){
cin>>op>>m1;
if(op==1){
change(i,m1,1);
}
else{
change(m1,1,1);
}
cout<<tr[1].ans<<endl;
}
}
return 0;
}
(还有我打线段树总是tle是为什么