#include<iostream>
using namespace std;
pair<int,string>a[100010];
pair<int,int>c[100010];
int main()
{
int n,m;
cin>>n>>m;
int k=0;
int b=m;
int d=n;
while(d--)
{
cin>>a[k].first>>a[k].second;
k++;
}
k=0;
while(b--)
{
cin>>c[k].first>>c[k].second;
k++;
}
int p=0;
for(int i=0;i<m;i++)
{
if(!c[i].first&&!a[p].first)
p-=c[i].second;
if(!c[i].first&&a[p].first)
p+=c[i].second;
if(c[i].first&&!a[p].first)
p+=c[i].second;
if(c[i].first&&a[p].first)
p-=c[i].second;
while(p<0)
p+=n;
if(p>=n)
{
p=p%n;
}
}
cout<<a[p].second;
return 0;
}