#include <bits/stdc++.h>
using namespace std;
const int MAXS = 2 * 10e2 + 5;
int n, m, k;
struct zar {
  int x, y, v;
};
struct zap {
  string s;
  int x1, y1, x2, y2;
};
long long buf[MAXS][MAXS];
long long dp[MAXS][MAXS];
void upd(int x, int y, long long val) {
  for (int x1 = x; x1 <= n; x1 = x1 + (x1 & (-x1)))
    for (int y1 = y; y1 <= m; y1 = y1 + (y1 & (-y1))) buf[x1][y1] += val;
}
long long qry(int x, int y) {
  long long sum = 0;
  for (int x1 = x; x1 > 0; x1 = x1 - (x1 & (-x1)))
    for (int y1 = y; y1 > 0; y1 = y1 - (y1 & (-y1))) sum += buf[x1][y1];
  return sum;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  vector<vector<zar>> lan(k);
  for (int i = 0; i < (k); ++i) {
    int len;
    cin >> len;
    lan[i].resize(len);
    for (int j = 0; j < (len); ++j)
      cin >> lan[i][j].x >> lan[i][j].y >> lan[i][j].v;
  }
  int q;
  cin >> q;
  vector<zap> que(q);
  vector<zap> bf1;
  for (int i = 0; i < (q); ++i) {
    cin >> que[i].s;
    if (que[i].s == "ASK") {
      cin >> que[i].x1 >> que[i].y1 >> que[i].x2 >> que[i].y2;
      bf1.push_back(que[i]);
    } else
      cin >> que[i].x1;
  }
  for (int i = 0; i < (k); ++i) {
    for (auto e : lan[i]) upd(e.x, e.y, e.v);
    for (int j = 0; j < (((int)(bf1).size())); ++j)
      dp[j][i] = qry(bf1[j].x2, bf1[j].y2) - qry(bf1[j].x1 - 1, bf1[j].y2) -
                 qry(bf1[j].x2, bf1[j].y1 - 1) +
                 qry(bf1[j].x1 - 1, bf1[j].y1 - 1);
    for (auto e : lan[i]) upd(e.x, e.y, -e.v);
  }
  int p = 0;
  bitset<MAXS> stan;
  for (int i = 0; i < (q); ++i) {
    if (que[i].s == "ASK") {
      long long temp = 0;
      for (int j = 0; j < (k); ++j) temp += stan[j] ? 0 : dp[p][j];
      cout << temp << "\n";
      p++;
    } else
      stan.flip(que[i].x1 - 1);
  }
  return 0;
}
