#include <bits/stdc++.h>
using namespace std;
struct Bulb {
  int x, y, w;
  Bulb() {
    x = 0;
    y = 0;
    w = 0;
  }
  Bulb(int _x, int _y, int _w) : x(_x), y(_y), w(_w) {}
};
struct Query {
  int x1, x2, y1, y2;
  Query(int _x1, int _y1, int _x2, int _y2) {
    x1 = _x1;
    y1 = _y1;
    x2 = _x2;
    y2 = _y2;
  }
  Query() {}
} cood[1000010];
vector<Bulb> gar[2010];
vector<int> query[1000010];
long long c[2010][2010], ans[1000010];
int l[2010], work[2010], n, m, k, q;
inline int lowbit(int x) { return x & (-x); }
void modify(int x, int y, int w) {
  for (int i = x; i <= n; i += lowbit(i)) {
    for (int j = y; j <= m; j += lowbit(j)) {
      c[i][j] += w;
    }
  }
}
long long ask(int x, int y) {
  long long ret = 0;
  for (int i = x; i > 0; i -= lowbit(i)) {
    for (int j = y; j > 0; j -= lowbit(j)) {
      ret += c[i][j];
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &l[i]);
    work[i] = 1;
    for (int j = 1; j <= l[i]; j++) {
      int x, y, w;
      scanf("%d%d%d", &x, &y, &w);
      gar[i].push_back(Bulb(x, y, w));
    }
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    char opt[10];
    int x;
    scanf("%s", opt);
    if (opt[0] == 'S') {
      scanf("%d", &x);
      work[x] = work[x] ^ 1;
    }
    if (opt[0] == 'A') {
      scanf("%d%d%d%d", &cood[i].x1, &cood[i].y1, &cood[i].x2, &cood[i].y2);
      for (int j = 1; j <= k; j++) {
        if (work[j]) {
          query[j].push_back(i);
        }
      }
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < l[i]; j++) {
      modify(gar[i][j].x, gar[i][j].y, gar[i][j].w);
    }
    for (int j = 0; j < query[i].size(); j++) {
      int k = query[i][j];
      ans[k] += ask(cood[k].x2, cood[k].y2) - ask(cood[k].x2, cood[k].y1 - 1) -
                ask(cood[k].x1 - 1, cood[k].y2) +
                ask(cood[k].x1 - 1, cood[k].y1 - 1);
    }
    for (int j = 0; j < l[i]; j++) {
      modify(gar[i][j].x, gar[i][j].y, -gar[i][j].w);
    }
  }
  for (int i = 1; i <= q; i++) {
    if (cood[i].x1) {
      printf("%I64d\n", ans[i]);
    }
  }
  return 0;
}
