代码如下
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;
struct men
{
int dir;
char job[];
void read()
{
scanf("%d %s" , &dir , &job);
}
}a[100005];
struct pro
{
int lr , step;
void in()
{
scanf("%d%d" , &lr , &step);
}
}b[100005];
int n , m , ans = 1;
int work(int num , int leri , int d , int st)
{
if (leri == d) return abs((num - st) % 7);
else return (num + st) % 7;
}
int main()
{
scanf("%d%d" , &n , &m);
for (int i = 1; i <= n; i++)
a[i].read();
for (int j = 1; j <= m; j++)
b[j].in();
for (int i = 1; i <= m; i++)
ans = work(ans , b[i].lr , a[ans].dir , b[i].step);
printf("%s" , a[ans].job);
return 0;
}