voidupdate(int k, int l, int r, int a, int b, int x){ if (b <= l || r <= a) { return; } elseif (a <= l && r <= b) { task[k] = x; } else { push_down(k); update(lc, l, m, a, b, x); update(rc, m, r, a, b, x); } }
intquery(int k, int l, int r, int a){ if (l == r - 1) { return task[k]; } else { push_down(k); if (a < m) return query(lc, l, m, a); elsereturn query(rc, m, r, a); } }
intmain(){ int T; scanf("%d", &T); for (int t = 1; t <= T; t++) { printf("Case #%d:\n", t); scanf("%d", &N); init(); for (int i = 1; i < N; i++) { int u, v; scanf("%d %d", &u, &v); G[v].push_back(u); leader[u] = false; }
int root = -1; for (int v = 1; v <= N; v++) { if (leader[v]) root = v; }
dfs(root); build();
scanf("%d", &M); for (int i = 0; i < M; i++) { char cmd; int x, y; scanf(" %c", &cmd); if (cmd == 'C') { scanf("%d", &x); printf("%d\n", query(0, 0, N, id[x])); } else { scanf("%d %d", &x, &y); update(0, 0, N, id[x], id[x] + size[x], y); }