#include <bits/stdc++.h>
using namespace std;
long long t[(2333)][(2333)];
int n, m;
void add(int x, int y, long long val) {
  if (x > n || y > m || x <= 0 || y <= 0) return;
  for (int i = x; i <= n; i += (i & (-i)))
    for (int j = y; j <= m; j += (j & (-j))) t[i][j] += val;
}
long long _query(int x, int y) {
  if (x > n || y > m || x <= 0 || y <= 0) return 0;
  long long rtn = 0;
  for (int i = x; i >= 1; i -= (i & (-i)))
    for (int j = y; j >= 1; j -= (j & (-j))) rtn += t[i][j];
  return rtn;
}
inline long long query(int xa, int ya, int xb, int yb) {
  return _query(xb, yb) - _query(xb, ya - 1) - _query(xa - 1, yb) +
         _query(xa - 1, ya - 1);
}
int a[(2333)], b[(2333)], c[(2333)], len[(2333)];
long long s[(2333)][(2333)];
int op[1000010], aa[(2333)], bb[(2333)], cc[(2333)], dd[(2333)];
int x[(2333)][(2333)], y[(2333)][(2333)], z[(2333)][(2333)];
bool open[(2333)];
inline void read(int &data) {
  bool inv = false;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') inv = true;
    ch = getchar();
  }
  data = 0;
  do {
    data = data * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  if (inv) data = -data;
}
int main(int argc, char *argv[]) {
  int k;
  read(n);
  read(m);
  read(k);
  for (int i = 1; i <= k; i++) {
    read(len[i]);
    for (int j = 1; j <= len[i]; j++) {
      read(x[i][j]);
      read(y[i][j]);
      read(z[i][j]);
    }
  }
  int q;
  read(q);
  char cmd[20];
  int cid = 1;
  for (int i = 1; i <= q; i++) {
    scanf("%s", cmd);
    if (cmd[0] == 'A') {
      op[i] = -1;
      read(aa[cid]);
      read(bb[cid]);
      read(cc[cid]);
      read(dd[cid]);
      cid++;
    } else {
      read(op[i]);
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= len[i]; j++) {
      add(x[i][j], y[i][j], z[i][j]);
    }
    for (int j = 1; j <= cid - 1; j++) {
      s[j][i] = query(aa[j], bb[j], cc[j], dd[j]);
    }
    for (int j = 1; j <= len[i]; j++) {
      add(x[i][j], y[i][j], -z[i][j]);
    }
  }
  cid = 1;
  for (int i = 1; i <= q; i++) {
    if (op[i] != -1)
      open[op[i]] = !open[op[i]];
    else {
      long long ans = 0;
      for (int j = 1; j <= k; j++) {
        if (!open[j]) ans += s[cid][j];
      }
      cid++;
      cout << ans << endl;
    }
  }
  return 0;
}
