#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
struct y
{
char cz;
int shu;
}yyy[200000];
int main()
{
int m,d,e=0,t=0,f=0;
cin>>m>>d;
for(int i=0;i<m;i++)
{
cin>>yyy[i].cz>>yyy[i].shu;
}
vector <int> hhh;
for(int i=0;i<m;i++)
{
if(yyy[i].cz=='A')
{
hhh.push_back((yyy[i].shu+t)%100);
e=e+1;
}
if(yyy[i].cz=='Q')
{
for(int j=e-1;j>=0;j--)
{
if(yyy[i].shu!=0)
{
if(f==0)
{f=j;yyy[i].shu=yyy[i].shu-1;}
if(hhh[j]>hhh[f]&&f!=0)
{f=j;yyy[i].shu=yyy[i].shu-1;}
}
if(yyy[i].shu==0)
{break;}
}
cout<<hhh[f]<<endl;
t=hhh[f];
}
}
return 0;
}