代码如下:
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
long n,m,x,y;
class Person
{
public:
string name;
long state;
}p[10010];
int main() {
cin >> n >> m;
for (long i = 0; i < n; ++i) {
cin >> p[i].state >> p[i].name;
}
long temp = 0;
for (long i = 1; i <= m; ++i) {
cin >> x >> y;
if (p[temp].state == 0 && x == 0)
{
temp = (temp - y + n) % n;
}
else if (p[temp].state == 0 && x == 1)
{
temp = (temp + y) % n;
}
else if (p[temp].state == 1 && x == 1)
{
temp = (temp - y + n) % n;
}
else if (p[temp].state == 1 && x == 0)
{
temp = (temp + y) % n;
}
}
cout << p[temp].name << endl;
system("pause");
return 0;
}