#include <bits/stdc++.h>
const int MAX_N = 2005;
const double eps = 1e-6;
const int inf = (int)1e9 + 123;
using namespace std;
int n, m, k;
vector<pair<pair<int, int>, int> > q[MAX_N];
bool type[MAX_N];
vector<int> need[MAX_N];
struct Query {
  int x, y, x2, y2;
  Query() {}
  Query(int x, int y, int x2, int y2) : x(x), y(y), x2(x2), y2(y2) {}
} shit[(int)1e6 + 5];
long long ans[(int)1e6 + 5];
long long first[MAX_N][MAX_N];
void upd(int x, int y, int delta) {
  for (int i = x; i <= n; i |= (i + 1))
    for (int j = y; j <= m; j |= (j + 1)) first[i][j] += delta;
}
long long get(int x, int y) {
  long long res = 0;
  for (int i = x; i >= 0; i = (i & (i + 1)) - 1)
    for (int j = y; j >= 0; j = (j & (j + 1)) - 1) res += first[i][j];
  return res;
}
long long calc(int x, int y, int x2, int y2) {
  return get(x2, y2) - get(x - 1, y2) - get(x2, y - 1) + get(x - 1, y - 1);
}
char second[10];
int sz = 0;
bool read() {
  sz = 0;
  while (true) {
    char now = getchar();
    if (now >= 'A' && now <= 'Z')
      second[sz++] = now;
    else
      break;
  }
  return second[0] == 'A';
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1, len; i <= k; i++) {
    scanf("\n%d", &len);
    q[i].resize(len);
    for (int j = 0; j < len; j++)
      scanf("\n%d %d %d", &q[i][j].first.first, &q[i][j].first.second,
            &q[i][j].second);
    type[i] = 1;
  }
  int query;
  scanf("\n%d", &query);
  int x, y, x2, y2;
  for (int i = 1; i <= query; i++) {
    scanf("\n");
    if (!read()) {
      int id;
      scanf("%d", &id);
      type[id] ^= 1;
    } else {
      scanf("%d %d %d %d", &x, &y, &x2, &y2);
      for (int j = 1; j <= k; j++)
        if (type[j]) need[j].push_back(i);
      shit[i] = Query(x, y, x2, y2);
    }
  }
  for (int i = 1; i <= k; i++) {
    for (auto j : q[i]) upd(j.first.first, j.first.second, j.second);
    for (auto j : need[i])
      ans[j] += calc(shit[j].x, shit[j].y, shit[j].x2, shit[j].y2);
    for (auto j : q[i]) upd(j.first.first, j.first.second, -j.second);
  }
  for (int i = 1; i <= query; i++)
    if (shit[i].x)
      printf(
          "%lld"
          "\n",
          ans[i]);
  return 0;
}
