90分:
#include<iostream>
using namespace std;
struct pep{
bool f;
string name;
};
int n,m,now=1;
pep a[100005];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i].f>>a[i].name;
while(m--){
bool dir;
int cnt;
cin>>dir>>cnt;
dir=dir^a[now].f;
if(dir)now+=cnt;
else now+=(n-cnt);
now=now%n;
}
cout<<a[now].name;
return 0;
}