#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
struct BIT {
  long long f[2010][2010];
  void modify(int x, int y, int c) {
    for (int i = x; i <= 2000; i += ((i) & (-i)))
      for (int j = y; j <= 2000; j += ((j) & (-j))) f[i][j] += c;
  }
  long long query(int x, int y) {
    long long sum = 0;
    for (int i = x; i; i -= ((i) & (-i)))
      for (int j = y; j; j -= ((j) & (-j))) sum += f[i][j];
    return sum;
  }
  long long get(int x1, int y1, int x2, int y2) {
    return query(x2, y2) + query(x1 - 1, y1 - 1) - query(x1 - 1, y2) -
           query(x2, y1 - 1);
  }
} t;
struct Node {
  int x;
  int y;
  int w;
};
std::vector<Node> vec[2010];
bool sit[2010][2010], have[2010];
int sx[2010], sy[2010], ex[2010], ey[2010];
long long ans[2010];
int main() {
  int n = inp();
  int m = inp();
  int k = inp();
  for (int i = 1; i <= k; i++) {
    int len = inp();
    while (len--) {
      int x = inp();
      int y = inp();
      int w = inp();
      vec[i].push_back((Node){x, y, w});
    }
  }
  memset(have, true, sizeof(have));
  int q = inp();
  int cc = 0;
  while (q--) {
    char type[10];
    scanf("%s", type + 1);
    if (type[1] == 'S') {
      have[inp()] ^= 1;
    } else {
      cc++;
      sx[cc] = inp();
      sy[cc] = inp();
      ex[cc] = inp();
      ey[cc] = inp();
      memcpy(sit[cc], have, sizeof(have));
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < vec[i].size(); j++)
      t.modify(vec[i][j].x, vec[i][j].y, vec[i][j].w);
    for (int j = 1; j <= cc; j++)
      if (sit[j][i]) ans[j] += t.get(sx[j], sy[j], ex[j], ey[j]);
    for (int j = 0; j < vec[i].size(); j++)
      t.modify(vec[i][j].x, vec[i][j].y, -vec[i][j].w);
  }
  for (int i = 1; i <= cc; i++) std::cout << ans[i] << std::endl;
}
