#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
char s[20];
long long a[N][N], Ans[N][N], flag[N];
int n, m, k, cnt, C;
pair<int, int> Mission[1000005];
struct data {
  int x, y, z;
};
struct matrix {
  int x, y, x2, y2;
};
vector<data> A[N];
vector<matrix> Q;
void modify(int x, int y, long long z) {
  for (int i = x; i <= n; i += i & -i)
    for (int j = y; j <= m; j += j & -j) a[i][j] += z;
  return;
}
long long ask(int x, int y) {
  long long ret = 0;
  for (int i = x; i; i -= i & -i)
    for (int j = y; j; j -= j & -j) ret += a[i][j];
  return ret;
}
long long Query(int x, int y, int x2, int y2) {
  return ask(x2, y2) + ask(x - 1, y - 1) - ask(x2, y - 1) - ask(x - 1, y2);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int num, i = 1; i <= k; i++) {
    scanf("%d", &num);
    for (int x, y, z, j = 1; j <= num; j++) {
      scanf("%d%d%d", &x, &y, &z);
      A[i].push_back((data){x, y, z});
    }
  }
  scanf("%d", &C);
  for (int i = 1; i <= C; i++) {
    scanf("%s", s);
    if (s[0] == 'A') {
      int x, y, x2, y2;
      cnt++;
      scanf("%d%d%d%d", &x, &y, &x2, &y2);
      Q.push_back((matrix){x, y, x2, y2});
      Mission[i] = make_pair(1, cnt - 1);
    }
    if (s[0] == 'S') {
      int x;
      scanf("%d", &x);
      Mission[i] = make_pair(2, x);
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < A[i].size(); j++)
      modify(A[i][j].x, A[i][j].y, A[i][j].z);
    for (int j = 0; j < Q.size(); j++)
      Ans[i][j] = Query(Q[j].x, Q[j].y, Q[j].x2, Q[j].y2);
    for (int j = 0; j < A[i].size(); j++)
      modify(A[i][j].x, A[i][j].y, -A[i][j].z);
  }
  for (int i = 1; i <= C; i++) {
    if (Mission[i].first == 1) {
      long long Res = 0;
      for (int j = 1; j <= k; j++)
        if (!flag[j]) Res += Ans[j][Mission[i].second];
      printf("%I64d\n", Res);
    } else
      flag[Mission[i].second] ^= 1;
  }
  return 0;
}
