#include <bits/stdc++.h>
using ull = long long;
ull tree[2001][2001];
int x[2001][2001];
int qx[2001][2];
int qy[2001][2];
int y[2001][2001];
int w[2001][2001];
ull a[2001][2001];
int n;
int m;
void add(int x, int y, int val) {
  for (int i = x; i <= n; i += (i & (-i))) {
    for (int j = y; j <= m; j += (j & (-j))) {
      tree[i][j] += ((ull)val);
    }
  }
}
ull query(int x, int y) {
  ull t;
  t = 0;
  for (int i = x; i; i -= (i & (-i))) {
    for (int j = y; j; j -= (j & (-j))) {
      t += tree[i][j];
    }
  }
  return t;
}
int main() {
  std::ios::sync_with_stdio(false);
  int k;
  int index;
  int len[2001];
  ull t;
  int ask;
  int q;
  char str[6];
  int op[1000000];
  bool s[2001];
  scanf("%d%d%d", &n, &m, &k);
  ask = 0;
  for (index = 0; index < k; ++index) {
    scanf("%d", &len[index]);
    for (int i = 0; i < len[index]; ++i) {
      scanf("%d%d%d", &x[index][i], &y[index][i], &w[index][i]);
    }
  }
  scanf("%d", &q);
  for (index = 0; index < q; ++index) {
    scanf("%s", str);
    if ('A' == str[0]) {
      scanf("%d%d%d%d", &qx[ask][0], &qy[ask][0], &qx[ask][1], &qy[ask][1]);
      ++ask;
      op[index] = 0;
    } else {
      scanf("%d", &op[index]);
    }
  }
  for (int i = 0; i < k; ++i) {
    for (index = 0; index < len[i]; ++index) {
      add(x[i][index], y[i][index], w[i][index]);
    }
    for (index = 0; index < ask; ++index) {
      a[index][i] = query(qx[index][1], qy[index][1]) -
                    query(qx[index][1], qy[index][0] - 1) -
                    query(qx[index][0] - 1, qy[index][1]) +
                    query(qx[index][0] - 1, qy[index][0] - 1);
    }
    for (index = 0; index < len[i]; ++index) {
      add(x[i][index], y[i][index], -w[i][index]);
    }
  }
  for (index = 0; index < k; ++index) {
    s[index] = true;
  }
  ask = 0;
  for (index = 0; index < q; ++index) {
    if (op[index]) {
      s[op[index] - 1] = !s[op[index] - 1];
    } else {
      t = 0;
      for (int i = 0; i < k; ++i) {
        if (s[i]) {
          t += a[ask][i];
        }
      }
      printf("%I64d\n", t);
      ++ask;
    }
  }
  return 0;
}
