#include <bits/stdc++.h>
using namespace std;
int n, m, K, q;
int len[2100], vis[2100][2100], cnt;
char s[11];
struct node {
  int x, y;
  void read() { scanf("%d%d", &x, &y); }
} l[2100], r[2100], a[2100][2100];
int v[2100][2100];
long long ans[2100], tr[2100][2100];
void insert(int x, int y, int v) {
  if (!x || !y) return;
  for (int i = x; i <= n; i += i & -i)
    for (int j = y; j <= m; j += j & -j) tr[i][j] += v;
}
long long query(int x, int y) {
  long long ret = 0;
  for (int i = x; i > 0; i -= i & -i)
    for (int j = y; j > 0; j -= j & -j) ret += tr[i][j];
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= K; i++) {
    scanf("%d", &len[i]);
    for (int j = 1; j <= len[i]; j++) a[i][j].read(), scanf("%d", &v[i][j]);
    vis[1][i] = 1;
  }
  scanf("%d", &q);
  for (int x; q--;) {
    scanf("%s", s);
    if (s[0] == 'S')
      scanf("%d", &x), vis[cnt + 1][x] ^= 1;
    else {
      l[++cnt].read();
      r[cnt].read();
      for (int i = 1; i <= K; i++) vis[cnt + 1][i] = vis[cnt][i];
    }
  }
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= len[i]; j++) insert(a[i][j].x, a[i][j].y, v[i][j]);
    for (int j = 1; j <= cnt; j++)
      if (vis[j][i])
        ans[j] += query(r[j].x, r[j].y) + query(l[j].x - 1, l[j].y - 1) -
                  query(r[j].x, l[j].y - 1) - query(l[j].x - 1, r[j].y);
    for (int j = 1; j <= len[i]; j++) insert(a[i][j].x, a[i][j].y, -v[i][j]);
  }
  for (int i = 1; i <= cnt; i++) printf("%I64d\n", ans[i]);
  return 0;
}
