就是一个简单模拟
#include<iostream>
#include<string>
using namespace std;
const int maxn=1e5+;
int in[maxn], x[maxn], y[maxn];
string name[maxn];
int h; int n, m;
int main(){
cin>>n>>m;
for(int i=;i<n;++i)cin>>in[i]>>name[i];
for(int i=;i<m;++i)cin>>x[i]>>y[i];
h=;
for(int i=;i<m;++i){
if(in[h]==){
if(x[i]==)h-=y[i];
else h+=y[i];
h%=n; h=(h+n)%n;
}else{
if(x[i]==)h+=y[i];
else h-=y[i];
h%=n; h=(h+n)%n;
}
}
cout<<name[h]<<endl;
}