Codeforces Round #807 (Div. 2) C. Mark and His Unfinished Essay
include <bits/stdc++.h>
define int long long
using namespace std;
int n, c, q;
string s;
int l[45], r[45], len[45];
signed main() {
int t;
cin >> t;
while(t--) {
cin >> n >> c >> q;
cin >> s;
len[0] = n;
for(int i = 1; i <= c; i++) {
cin >> l[i] >> r[i];
len[i] = len[i - 1] + r[i] - l[i] + 1;//len i表示进行完第i次操作后的长度
}
for(int i = 0; i <= q - 1; i++) {
int k;
cin >> k;
int fuck = k;//fuck表示字符在这次操作前那个串的位置
for(int j = c; j >= 1; j--) {
if(fuck > len[j - 1]) //第j次操作没有影响 不必更新fuck
fuck = fuck - len[j - 1] + l[j] - 1;
}
cout << s[fuck - 1] << endl;
}
}
return 0;
}