#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>order_set;
typedef pair<int, int>pr;
#define all(i)     i.begin() , i.end()
#define ft     first
#define sn     second
#define pb push_back

#define totalone(mask) __builtin_popcount(mask)
#define chkbit(mask,bit) (mask&(1LL << bit))
#define setbit(mask,bit) (mask|(1LL << bit))
#define cngbit(mask,bit) (mask^(1LL << bit))

#define en "\n"
#define dbg(x) cerr<<#x<<" is : "<<x<<en;
#define here cout<<"rony\n"
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define report cout<<-1<<en;
#define sum(n) ((1LL*(n)*(n+1))/ 2LL)
#define sqr(n) (1LL*(n)*(n))
#define vag(a,b) ((a + b - 1)/b)
#define coutv(v) for(auto i: v) cout<<i<<" ";cout<<en;
#define cinv(v) for(auto &i: v) cin >> i;

#define MAXN 100001
#define inf 1e6+5
const int mod = 1e9 + 7;

vector<int>g[MAXN];
int vis[MAXN];

struct segment_tree
{
    struct NODE {
        int st , EN, value;// start , end

        void init(int L, int R) {
            st = L, EN = R;
            value = 0;
        }
    } g[4 * MAXN];

    void build(int CN, int L, int R)
    {
        g[CN].init(L, R);

        if (L == R ) return;
        int mid = (L + R) >> 1;
        int LN = CN << 1;

        build(LN, L, mid);
        build(LN | 1, mid + 1, R);
    }

    void update(int CN, int l, int r)
    {
        int x = g[CN].st;
        int y = g[CN].EN;
        if (y < l || x > r) return;

        if (l <= x && r >= y ) {
            g[CN].value += 1;
            // dbg(x);
            return;
        }

        update(CN * 2, l, r);
        update(CN * 2 + 1, l, r);
    }

    int query(int CN, int id, int carry)
    {
        int x = g[CN].st;
        int y = g[CN].EN;
        if (y < id || x > id) return 0;

        if (id <= x && id >= y ) {
            return g[CN].value + carry;
        }

        int ans = query(CN * 2, id, carry + g[CN].value);
        ans += query(CN * 2 + 1, id, carry + g[CN].value);
        return ans;
    }

} s_tree;
void solve()
{
    string s;
    cin >> s;
    int q;
    cin >> q;

    int n = s.size();
    s_tree.build(1, 1, n);

    while (q--)
    {
        char c; int x, y;
        cin >> c;
        if (c == 'I') {
            cin >> x >> y;
            s_tree.update(1, x, y);
        }
        else {
            cin >> x;
            int an = s_tree.query(1, x, 0) % 2;
            if (an) cout << (s[x - 1] == '0' ? '1' : '0') << en;
            else cout << s[x - 1] << en;
       
        }
    }
}
int main()
{
    IOS;
    ll t;
    t = 1;
    cin >> t;
    int c = 0;
    while ( t-- )
    {
        cout << "Case " << ++c << ":\n";
        solve();
    }
    return 0;
}