#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
struct node
{
    char val;
    int sz;
    node *fa, *ch[2];
#define _get(x, y) \
    int get##x() { return this == 0 ? (y) : this->x; }
    _get(sz, 0)
} * root;
const int N = 2e6 + 50;
struct
{
    int cnt;
    node pool[N];
    void init()
    {
        cnt = 0;
    }
    inline node *alloc() { return &pool[cnt++]; }
} mem;
char a[N];
inline int dir(node *x)
{
    node *f = x->fa;
    if (f == 0)
        return -1;
    else
        return x == f->ch[1];
}
inline void update(node *x)
{
    node *lc = x->ch[0], *rc = x->ch[1];
    x->sz = lc->getsz() + rc->getsz() + 1;
}
node *build_tree(int l, int r, node *f)
{
    node *newNode = mem.alloc();
    int m = l + ((r - l) >> 1);
    newNode->fa = f;
    newNode->val = a[m];
    newNode->ch[0] = l < m ? build_tree(l, m - 1, newNode) : 0;
    newNode->ch[1] = m < r ? build_tree(m + 1, r, newNode) : 0;
    update(newNode);
    return newNode;
}
inline void liftup(node *x)
{
    node *f = x->fa;
    if (f == 0) return;
    int d = dir(x);
    node *ff = f->fa, *c = x->ch[d ^ 1];
    if (ff == 0)
        root = x;
    else
        ff->ch[dir(f)] = x;
    x->fa = ff, f->fa = x, x->ch[d ^ 1] = f, f->ch[d] = c;
    if (c) c->fa = f;
    update(f), update(x);
}
inline void splay(node *x, node *target)
{
    if (x == 0) return;
    node *f = 0, *ff = 0;
    while ((f = x->fa) != target)
        if ((ff = f->fa) == target)
            liftup(x);
        else if (dir(x) ^ dir(f))
            liftup(x), liftup(x);
        else
            liftup(f), liftup(x);
}
node *kth(node *x, int k)
{
    if (x->ch[0]->getsz() == k - 1)
        return x;
    else if (x->ch[0]->getsz() > k - 1)
        return kth(x->ch[0], k);
    else
        return kth(x->ch[1], k - x->ch[0]->getsz() - 1);
}
void _printTree(node *root)
{
    if (root == nullptr) return;
    _printTree(root->ch[0]);
    putchar(root->val);
    _printTree(root->ch[1]);
}
void printTree(node *root)
{
    printf("T(@%d): [", __LINE__);
    _printTree(root);
    puts("]");
}
int main()
{
    mem.init();
    scanf("%s", a + 1);
    int n = strlen(a + 1);
    int m;
    scanf("%d", &m);
    root = build_tree(0, n + 1, 0);
    while (m--)
    {
        char op[4];
        int v;
        scanf("%s%d", op, &v);
        if (*op == 'A')
        {
            splay(kth(root, v + 1), 0);
            printf("%c\n", root->val);
        }
        if (*op == 'M')
        {
            if (v > 0)
            {
                splay(kth(root, v + 2), 0);
                splay(kth(root->ch[0], 1), root);
                auto subTree = root->ch[0]->ch[1];
                root->ch[0]->ch[1] = 0;
                update(root->ch[0]), update(root);
                splay(kth(root, n - v + 1), 0);
                splay(kth(root->ch[1], 1), root);
                root->ch[1]->ch[0] = subTree;
                subTree->fa = root->ch[1];
                update(root->ch[1]), update(root);
            }
            if (v < 0)
            {
                splay(kth(root, n + v + 1), 0);
                splay(kth(root->ch[1], -v + 1), root);
                auto subTree = root->ch[1]->ch[0];
                root->ch[1]->ch[0] = 0;
                update(root->ch[1]), update(root);
                splay(kth(root, 2), 0);
                splay(kth(root->ch[0], 1), root);
                root->ch[0]->ch[1] = subTree;
                subTree->fa = root->ch[0];
                update(root->ch[0]), update(root);
            }
        }
    }
    return 0;
}