#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
long long g[N][N], score[N][N];
void update(int x, int y, int val) {
  while (x < N) {
    int idx = y;
    while (idx < N) {
      g[x][idx] += val;
      idx += (idx & -idx);
    }
    x += (x & -x);
  }
}
long long read(int x, int y) {
  long long res = 0;
  while (x > 0) {
    int idx = y;
    while (idx > 0) {
      res += g[x][idx];
      idx -= (idx & -idx);
    }
    x -= (x & -x);
  }
  return res;
}
long long rect(int x1, int y1, int x2, int y2) {
  long long res =
      read(x2, y2) - read(x2, y1 - 1) - read(x1 - 1, y2) + read(x1 - 1, y1 - 1);
  return res;
}
int a[N], b[N], c[N], d[N], x[N][N], y[N][N], w[N][N], len[N];
char s[10];
int type[N * N];
int main() {
  set<int> active;
  int n, m, k, t = 0, q;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < k; ++i) {
    scanf("%d", &len[i]);
    for (int j = 0; j < len[i]; ++j) {
      scanf("%d %d %d", x[i] + j, y[i] + j, w[i] + j);
    }
    active.insert(i);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf(" %s", s);
    if (s[0] == 'A') {
      scanf("%d %d %d %d", &a[t], &b[t], &c[t], &d[t]);
      type[i] = -1;
      ++t;
    } else {
      scanf("%d", type + i);
      --type[i];
    }
  }
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < len[i]; ++j) {
      update(x[i][j], y[i][j], w[i][j]);
    }
    for (int j = 0; j < t; ++j) {
      score[j][i] = rect(a[j], b[j], c[j], d[j]);
    }
    for (int j = 0; j < len[i]; ++j) {
      update(x[i][j], y[i][j], -w[i][j]);
    }
  }
  t = 0;
  for (int i = 0; i < q; ++i) {
    if (type[i] == -1) {
      long long res = 0;
      for (auto it : active) {
        res += score[t][it];
      }
      printf("%lld\n", res);
      ++t;
    } else {
      if (active.count(type[i])) {
        active.erase(type[i]);
      } else {
        active.insert(type[i]);
      }
    }
  }
  return 0;
}
