#include <bits/stdc++.h>
using namespace std;
long long va[2005][2005];
vector<pair<pair<long long, long long>, long long> > block[2005];
vector<int> up[2005];
struct node {
  int x1, y1, x2, y2, flag;
  long long ans;
} que[2005 * 1005];
int n, m, l = 0, k;
char s[20];
void update(int X, int Y, long long tmp) {
  for (int i = X; i <= n; i += (i & (-i)))
    for (int j = Y; j <= m; j += (j & (-j))) va[i][j] += tmp;
}
long long query(int X, int Y) {
  long long ans = 0;
  for (int i = X; i; i -= (i & (-i)))
    for (int j = Y; j; j -= (j & (-j))) ans += va[i][j];
  return ans;
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int len;
    scanf("%d", &len);
    for (int j = 0; j < len; j++) {
      int X1, Y1;
      long long V;
      scanf("%d %d %I64d", &X1, &Y1, &V);
      block[i].push_back(make_pair(make_pair(X1, Y1), V));
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%s", s);
    if (s[0] == 'A') {
      scanf("%d %d %d %d", &que[l].x1, &que[l].y1, &que[l].x2, &que[l].y2);
      que[l].flag = i;
      l++;
    } else {
      int a;
      scanf("%d", &a);
      up[a].push_back(i);
    }
  }
  for (int i = 1; i <= k; i++) {
    up[i].push_back(10000000);
    for (int j = 0; j < block[i].size(); j++) {
      update(block[i][j].first.first, block[i][j].first.second,
             block[i][j].second);
    }
    int pre = 0, sym = 1;
    for (int j = 0; j < l; j++) {
      while (que[j].flag > up[i][pre]) {
        sym ^= 1;
        pre++;
      }
      if (sym) {
        int X1 = que[j].x1, Y1 = que[j].y1, X2 = que[j].x2, Y2 = que[j].y2;
        que[j].ans += query(X2, Y2) - query(X2, Y1 - 1) - query(X1 - 1, Y2) +
                      query(X1 - 1, Y1 - 1);
      }
    }
    for (int j = 0; j < block[i].size(); j++) {
      update(block[i][j].first.first, block[i][j].first.second,
             -1 * block[i][j].second);
    }
  }
  for (int i = 0; i < l; i++) printf("%I64d\n", que[i].ans);
  return 0;
}
