题目链接
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long
string s;
char check(char c,int t)
{
return char('A'+(c-'A'+t)%3);
}
char dfs(int t,int k)
{
if(t==0)return s[k];
if(k==0)return check(s[0],t);
return check(dfs(t-1,k/2),k%2+1);
}
signed main()
{
cin>>s;
int q;cin>>q;
while(q--)
{
int t,k;cin>>t>>k;
cout<<dfs(t,k-1)<<'\n';
}
}