#include <bits/stdc++.h>
using namespace std;
#define MAX 50005
#define mp make_pair
#define pb push_back
#define in(n) insert(n)
#define mod 1000000007
vector <int> vec[MAX];
long long arr[MAX], val[MAX], lazy[MAX];
int par[MAX], vis[MAX];
void dfs(int node) {
vis[node] = 1;
if (vec[node].size() == 0) {
arr[node] += lazy[node];
val[node] += lazy[node];
arr[node] %= mod;
val[node] %= mod;
return ;
}
for (int i = 0 ; i < vec[node].size() ; i++) {
if (vis[vec[node][i]] == 0) {
dfs(vec[node][i]);
lazy[node] += lazy[vec[node][i]];
lazy[node] %= mod;
val[node] += val[vec[node][i]];
val[node] %= mod;
}
}
val[node] += lazy[node];
arr[node] += lazy[node];
arr[node] %= mod;
val[node] %= mod;
}
int main() {
int t, m, n, q, x, y, i, j;
char dec[10];
scanf("%d", &t);
while (t--) {
scanf("%d %d %d", &n, &m, &q);
for (i = 1 ; i <= n ; i++) {
scanf("%d", &par[i]);
vec[par[i]].pb(i);
arr[i] = lazy[i] = vis[i] = val[i] = 0;
}
while (m--) {
scanf(" %s %d %d", dec, &x, &y);
if (strcmp(dec, "ADD") == 0) {
arr[x] += y;
val[x] += y;
}
else {
lazy[x] += y;
}
}
dfs(1);
while (q--) {
scanf(" %s %d", dec, &x);
if (strcmp(dec, "VALTREE") == 0) {
printf("%lld\n", val[x]);
}
else {
printf("%lld\n", arr[x]);
}
}
}
return 0;
}
ICAgICNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgogICAgdXNpbmcgbmFtZXNwYWNlIHN0ZDsKICAgICNkZWZpbmUgTUFYIDUwMDA1CiAgICAjZGVmaW5lIG1wIG1ha2VfcGFpcgogICAgI2RlZmluZSBwYiBwdXNoX2JhY2sKICAgICNkZWZpbmUgaW4obikgaW5zZXJ0KG4pCiAgICAjZGVmaW5lIG1vZCAxMDAwMDAwMDA3CiAgICB2ZWN0b3IgPGludD4gdmVjW01BWF07CiAgICBsb25nIGxvbmcgYXJyW01BWF0sIHZhbFtNQVhdLCBsYXp5W01BWF07CiAgICBpbnQgcGFyW01BWF0sIHZpc1tNQVhdOwogICAgIAogICAgdm9pZCBkZnMoaW50IG5vZGUpIHsKICAgICAgdmlzW25vZGVdID0gMTsKICAgICAgaWYgKHZlY1tub2RlXS5zaXplKCkgPT0gMCkgewogICAgICAgIGFycltub2RlXSArPSBsYXp5W25vZGVdOwogICAgICAgIHZhbFtub2RlXSArPSBsYXp5W25vZGVdOwogICAgICAgIGFycltub2RlXSAlPSBtb2Q7CiAgICAgICAgdmFsW25vZGVdICU9IG1vZDsKICAgICAgICByZXR1cm4gOwogICAgICB9CiAgICAgIGZvciAoaW50IGkgPSAwIDsgaSA8IHZlY1tub2RlXS5zaXplKCkgOyBpKyspIHsKICAgICAgICBpZiAodmlzW3ZlY1tub2RlXVtpXV0gPT0gMCkgewogICAgICAgICAgZGZzKHZlY1tub2RlXVtpXSk7CiAgICAgICAgICBsYXp5W25vZGVdICs9IGxhenlbdmVjW25vZGVdW2ldXTsKICAgICAgICAgICBsYXp5W25vZGVdICU9IG1vZDsKICAgICAgICAgIHZhbFtub2RlXSArPSB2YWxbdmVjW25vZGVdW2ldXTsKICAgICAgICAgIHZhbFtub2RlXSAlPSBtb2Q7CiAgICAgICAgfSAKICAgICAgfQogICAgICB2YWxbbm9kZV0gKz0gbGF6eVtub2RlXTsKICAgICAgYXJyW25vZGVdICs9IGxhenlbbm9kZV07CiAgICAgICAgYXJyW25vZGVdICU9IG1vZDsKICAgICAgICB2YWxbbm9kZV0gJT0gbW9kOwogICAgfQogICAgIAogICAgaW50IG1haW4oKSB7CiAgICAgIAogICAgICBpbnQgdCwgbSwgbiwgcSwgeCwgeSwgaSwgajsKICAgICAgY2hhciBkZWNbMTBdOwogICAgICBzY2FuZigiJWQiLCAmdCk7CiAgICAgIHdoaWxlICh0LS0pIHsKICAgICAgICBzY2FuZigiJWQgJWQgJWQiLCAmbiwgJm0sICZxKTsKICAgICAgICBmb3IgKGkgPSAxIDsgaSA8PSBuIDsgaSsrKSB7CiAgICAgICAgICAgc2NhbmYoIiVkIiwgJnBhcltpXSk7CiAgICAgICAgICAgdmVjW3BhcltpXV0ucGIoaSk7CiAgICAgICAgICAgYXJyW2ldID0gbGF6eVtpXSA9IHZpc1tpXSA9IHZhbFtpXSA9IDA7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChtLS0pIHsKICAgICAgICAgIHNjYW5mKCIgJXMgJWQgJWQiLCBkZWMsICZ4LCAmeSk7CiAgICAgICAgICBpZiAoc3RyY21wKGRlYywgIkFERCIpID09IDApIHsKICAgICAgICAgICAgYXJyW3hdICs9IHk7CiAgICAgICAgICAgIHZhbFt4XSArPSB5OwogICAgICAgICAgfSAKICAgICAgICAgIGVsc2UgewogICAgICAgICAgICBsYXp5W3hdICs9IHk7CiAgICAgICAgICB9CiAgICAgICB9CiAgICAgICBkZnMoMSk7CiAgICAgICB3aGlsZSAocS0tKSB7CiAgICAgICAgIHNjYW5mKCIgJXMgJWQiLCBkZWMsICZ4KTsKICAgICAgICAgaWYgKHN0cmNtcChkZWMsICJWQUxUUkVFIikgPT0gMCkgewogICAgICAgICAgICBwcmludGYoIiVsbGRcbiIsIHZhbFt4XSk7CiAgICAgICAgIH0gCiAgICAgICAgIGVsc2UgewogICAgICAgICAgICBwcmludGYoIiVsbGRcbiIsIGFyclt4XSk7CiAgICAgICAgIH0gCiAgICAgICB9CiAgICAgICB9ICAgICAgIAogICAgICAgcmV0dXJuIDA7CiAgICB9IA==