#include <bits/stdc++.h>
using namespace std;
string s;
int Q, N, M, k, t[1000100];
int len[3020], a[3020][3020], b[3020][3020], val[3020][3020];
long long AIB[3020][3020], ans[1000100];
vector<int> swp[3020];
struct query {
  int x, y, x2, y2, ind;
  query(int xx, int yy, int xx2, int yy2, int in) {
    x = xx, y = yy, x2 = xx2, y2 = yy2, ind = in;
  }
};
vector<query> q;
inline int zeros(int x) { return x & (-x); }
void update(int x, int y, int val) {
  while (y <= M) {
    AIB[x][y] += val;
    y += zeros(y);
  }
}
void add(int x, int y, int val) {
  while (x <= N) {
    update(x, y, val);
    x += zeros(x);
  }
}
long long sum2(int x, int y) {
  long long ret = 0;
  while (y) {
    ret += AIB[x][y];
    y -= zeros(y);
  }
  return ret;
}
long long sum(int x, int y) {
  long long ret = 0;
  while (x) {
    ret += sum2(x, y);
    x -= zeros(x);
  }
  return ret;
}
long long cnt(int x, int y, int x2, int y2) {
  return sum(x2, y2) - sum(x - 1, y2) - sum(x2, y - 1) + sum(x - 1, y - 1);
}
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) {
      scanf("%d%d%d", &a[i][j], &b[i][j], &val[i][j]);
    }
  }
  scanf("%d", &Q);
  for (int i = 1; i <= Q; ++i) {
    int x, y, x2, y2;
    cin >> s;
    if (s == "ASK") {
      t[i] = 1;
      scanf("%d%d%d%d", &x, &y, &x2, &y2);
      q.push_back(query(x, y, x2, y2, i));
    } else {
      scanf("%d", &x);
      swp[x].push_back(i);
    }
  }
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= len[i]; ++j) {
      add(a[i][j], b[i][j], val[i][j]);
    }
    int curr = 1, in = 0;
    for (auto qr : q) {
      while (in < swp[i].size() && swp[i][in] < qr.ind) {
        curr = 1 - curr;
        ++in;
      }
      if (curr) {
        ans[qr.ind] += cnt(qr.x, qr.y, qr.x2, qr.y2);
      }
    }
    for (int j = 1; j <= len[i]; ++j) {
      add(a[i][j], b[i][j], -val[i][j]);
    }
  }
  for (int i = 1; i <= Q; ++i) {
    if (t[i] == 1) {
      printf("%I64d\n", ans[i]);
    }
  }
  return 0;
}
