#include <bits/stdc++.h>
using namespace std;
int n, m, c, num, z;
int fa[2] = {-1, 1}, f;
struct mode {
int head;
string name;
} a[100001];
int main() {
cin >> n >> m;
for(int i = 0; i < n; i++) {
cin >> a[i].head >> a[i].name;
}
for(int i = 0; i < m; i++) {
cin >> c >> num;
if((a[z].head == 0 && c == 0) || (a[z].head == 1 && c == 1)) {
if(z - num < 0) z = z - num + n;
else z -= num;
}
if((a[z].head == 1 && c == 0) || (a[z].head == 1 && c == 0)) {
if(z + num > n) z = z + num - n;
else z += num;
}
}
cout << a[z].name << endl;
return 0;
}
看不出来哪里有问题,求调