#include <bits/stdc++.h>
int n, m, r, q;
long long ans;
int siz[2010], X[2010][2010], Y[2010][2010], V[2010][2010];
int OP[1000010], X1[2010], Y1[2010], X2[2010], Y2[2010];
short isOff[2010];
long long tree[2010][2010], cont[2010][2010];
void add(int x, int y, int val) {
  int i, j;
  for (i = x; i <= n; i += i & (-i))
    for (j = y; j <= m; j += j & (-j)) tree[i][j] += val;
}
long long query(int x, int y) {
  int i, j;
  long long ret = 0;
  for (i = x; i; i -= i & (-i))
    for (j = y; j; j -= j & (-j)) ret += tree[i][j];
  return ret;
}
int main() {
  int i, j, tot, mehh;
  char s[10];
  scanf("%d%d%d", &n, &m, &r);
  for (i = 1; i <= r; i++) {
    scanf("%d", &siz[i]);
    for (j = 1; j <= siz[i]; j++) scanf("%d%d%d", &X[i][j], &Y[i][j], &V[i][j]);
  }
  scanf("%d", &q);
  for (i = 1, tot = 0; i <= q; i++) {
    scanf("%s", s);
    if (s[0] == 'A') {
      OP[i] = 0;
      tot++;
      scanf("%d%d%d%d", &X1[tot], &Y1[tot], &X2[tot], &Y2[tot]);
    } else
      scanf("%d", &OP[i]);
  }
  for (i = 1; i <= r; i++) {
    for (j = 1; j <= siz[i]; j++) add(X[i][j], Y[i][j], V[i][j]);
    for (j = 1; j <= tot; j++)
      cont[j][i] = query(X2[j], Y2[j]) - query(X2[j], Y1[j] - 1) -
                   query(X1[j] - 1, Y2[j]) + query(X1[j] - 1, Y1[j] - 1);
    for (j = 1; j <= siz[i]; j++) add(X[i][j], Y[i][j], -V[i][j]);
  }
  for (i = 1, tot = 0; i <= q; i++) {
    if (OP[i] > 0)
      isOff[OP[i]] ^= 1;
    else {
      tot++;
      ans = 0;
      for (j = 1; j <= r; j++)
        if (!isOff[j]) ans += cont[tot][j];
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
