#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;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGludCBsbDsKI2RlZmluZSBJT1MgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsgIGNpbi50aWUoMCk7IGNvdXQudGllKDApOwoKI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgojaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4KdXNpbmcgbmFtZXNwYWNlIF9fZ251X3BiZHM7Cgp0eXBlZGVmIHRyZWU8aW50LCBudWxsX3R5cGUsIGxlc3M8aW50PiwgcmJfdHJlZV90YWcsIHRyZWVfb3JkZXJfc3RhdGlzdGljc19ub2RlX3VwZGF0ZT5vcmRlcl9zZXQ7CnR5cGVkZWYgcGFpcjxpbnQsIGludD5wcjsKI2RlZmluZSBhbGwoaSkgICAgIGkuYmVnaW4oKSAsIGkuZW5kKCkKI2RlZmluZSBmdCAgICAgZmlyc3QKI2RlZmluZSBzbiAgICAgc2Vjb25kCiNkZWZpbmUgcGIgcHVzaF9iYWNrCgojZGVmaW5lIHRvdGFsb25lKG1hc2spIF9fYnVpbHRpbl9wb3Bjb3VudChtYXNrKQojZGVmaW5lIGNoa2JpdChtYXNrLGJpdCkgKG1hc2smKDFMTCA8PCBiaXQpKQojZG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sKCiAgICAgICAgaWYgKEwgPT0gUiApIHJldHVybjsKICAgICAgICBpbnQgbWlkID0gKEwgKyBSKSA+PiAxOwogICAgICAgIGludCBMTiA9IENOIDw8IDE7CgogICAgICAgIGJ1aWxkKExOLCBMLCBtaWQpOwogICAgICAgIGJ1aWxkKExOIHwgMSwgbWlkICsgMSwgUik7CiAgICB9CgogICAgdm9pZCB1cGRhdGUoaW50IENOLCBpbnQgbCwgaW50IHIpCiAgICB7CiAgICAgICAgaW50IHggPSBnW0NOXS5zdDsKICAgICAgICBpbnQgeSA9IGdbQ05dLkVOOwogICAgICAgIGlmICh5IDwgbCB8fCB4ID4gcikgcmV0dXJuOwoKICAgICAgICBpZiAobCA8PSB4ICYmIHIgPj0geSApIHsKICAgICAgICAgICAgZ1tDTl0udmFsdWUgKz0gMTsKICAgICAgICAgICAgLy8gZGJnKHgpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQoKICAgICAgICB1cGRhdGUoQ04gKiAyLCBsLCByKTsKICAgICAgICB1cGRhdGUoQ04gKiAyICsgMSwgbCwgcik7CiAgICB9CgogICAgaW50IHF1ZXJ5KGludCBDTiwgaW50IGlkLCBpbnQgY2FycnkpCiAgICB7CiAgICAgICAgaW50IHggPSBnW0NOXS5zdDsKICAgICAgICBpbnQgeSA9IGdbQ05dLkVOOwogICAgICAgIGlmICh5IDwgaWQgfHwgeCA+IGlkKSByZXR1cm4gMDsKCiAgICAgICAgaWYgKGlkIDw9IHggJiYgaWQgPj0geSApIHsKICAgICAgICAgICAgcmV0dXJuIGdbQ05dLnZhbHVlICsgY2Fycnk7CiAgICAgICAgfQoKICAgICAgICBpbnQgYW5zID0gcXVlcnkoQ04gKiAyLCBpZCwgY2FycnkgKyBnW0NOXS52YWx1ZSk7CiAgICAgICAgYW5zICs9IHF1ZXJ5KENOICogMiArIDEsIGlkLCBjYXJyeSArIGdbQ05dLnZhbHVlKTsKICAgICAgICByZXR1cm4gYW5zOwogICAgfQoKfSBzX3RyZWU7CnZvaWQgc29sdmUoKQp7CiAgICBzdHJpbmcgczsKICAgIGNpbiA+PiBzOwogICAgaW50IHE7CiAgICBjaW4gPj4gcTsKCiAgICBpbnQgbiA9IHMuc2l6ZSgpOwogICAgc190cmVlLmJ1aWxkKDEsIDEsIG4pOwoKICAgIHdoaWxlIChxLS0pCiAgICB7CiAgICAgICAgY2hhciBjOyBpbnQgeCwgeTsKICAgICAgICBjaW4gPj4gYzsKICAgICAgICBpZiAoYyA9PSAnSScpIHsKICAgICAgICAgICAgY2luID4+IHggPj4geTsKICAgICAgICAgICAgc190cmVlLnVwZGF0ZSgxLCB4LCB5KTsKICAgICAgICB9CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIGNpbiA+PiB4OwogICAgICAgICAgICBpbnQgYW4gPSBzX3RyZWUucXVlcnkoMSwgeCwgMCkgJSAyOwogICAgICAgICAgICBpZiAoYW4pIGNvdXQgPDwgKHNbeCAtIDFdID09ICcwJyA/ICcxJyA6ICcwJykgPDwgZW47CiAgICAgICAgICAgIGVsc2UgY291dCA8PCBzW3ggLSAxXSA8PCBlbjsKICAgICAgIAogICAgICAgIH0KICAgIH0KfQppbnQgbWFpbigpCnsKICAgIElPUzsKICAgIGxsIHQ7CiAgICB0ID0gMTsKICAgIGNpbiA+PiB0OwogICAgaW50IGMgPSAwOwogICAgd2hpbGUgKCB0LS0gKQogICAgewogICAgICAgIGNvdXQgPDwgIkNhc2UgIiA8PCArK2MgPDwgIjpcbiI7CiAgICAgICAgc29sdmUoKTsKICAgIH0KICAgIHJldHVybiAwOwp9