#include <bits/stdc++.h>
using namespace std;
void solve(int t) {
int N, M, Q;
cin >> N >> M >> Q;
string S;
cin >> S;
vector<string> v(M);
v[0] = S;
string risposta;
for (int i = 0; i < Q; i++) {
char type;
int a, b;
cin >> type >> a >> b;
if (type == 's') {
v[b].push_back(move(v[a].back()));
} else {
risposta.push_back(v[a][b]);
}
}
cout << "Case #" << t << ": " << risposta << endl;
}
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int T;
cin >> T;
for (int t = 1; t <= T; t++) {
solve(t);
}
return 0;
}
test case base li fa bene, con l’input dato da terry tutto errato, ho paura che sia per un overflow o cose del genere essendo che il file di testo dell’input pesa 26mb. non ho idea di cosa ho sbagliato, grazie in anticipo dell’aiuto