#include <bits/stdc++.h>
using namespace std;
long long bit[2010][2010];
void update(int r, int c, int val) {
  int i, j;
  for (i = r; i <= 2010; i += i & -i)
    for (j = c; j <= 2010; j += j & -j) bit[i][j] += val;
}
long long sum(int r, int c) {
  int i, j;
  long long s = 0;
  for (i = r; i > 0; i &= i - 1)
    for (j = c; j > 0; j &= j - 1) s += bit[i][j];
  return s;
}
vector<pair<int, int> > grd[2010];
map<pair<int, int>, int> mp;
struct Query {
  char typ;
  int nowst;
  long long ans;
  int a, b, c, d;
  Query() {
    nowst = 1;
    ans = 0;
  }
};
vector<int> query[2010];
Query tmp[1000010];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int len;
    scanf("%d", &len);
    for (int j = 1; j <= len; j++) {
      int x, y, vl;
      scanf("%d %d %d", &x, &y, &vl);
      grd[i].push_back(make_pair(x, y));
      mp[make_pair(x, y)] = vl;
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    char s[50];
    scanf("%s", s);
    if (s[0] == 'A') {
      int a, b, c, d;
      scanf("%d %d %d %d", &a, &b, &c, &d);
      tmp[i].typ = 'A';
      tmp[i].a = a;
      tmp[i].b = b;
      tmp[i].c = c;
      tmp[i].d = d;
      for (int x = 1; x <= k; x++) {
        query[x].push_back(i);
      }
    } else {
      int a;
      scanf("%d", &a);
      tmp[i].nowst ^= 1;
      tmp[i].typ = 'S';
      query[a].push_back(i);
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < grd[i].size(); j++) {
      update(grd[i][j].first, grd[i][j].second,
             mp[make_pair(grd[i][j].first, grd[i][j].second)]);
    }
    int cnt = 0;
    vector<int> onnn;
    vector<int> offf;
    for (int j = 0; j < query[i].size(); j++) {
      if (tmp[query[i][j]].typ == 'S') {
        cnt++;
      } else {
        if (cnt % 2 == 0)
          onnn.push_back(j);
        else
          offf.push_back(j);
      }
    }
    for (int j = 0; j < onnn.size(); j++) {
      int a, b, c, d;
      a = tmp[query[i][onnn[j]]].a;
      b = tmp[query[i][onnn[j]]].b;
      c = tmp[query[i][onnn[j]]].c;
      d = tmp[query[i][onnn[j]]].d;
      tmp[query[i][onnn[j]]].ans +=
          (sum(c, d) - sum(c, b - 1) - sum(a - 1, d) + sum(a - 1, b - 1));
    }
    for (int j = 0; j < grd[i].size(); j++) {
      update(grd[i][j].first, grd[i][j].second,
             -mp[make_pair(grd[i][j].first, grd[i][j].second)]);
    }
  }
  for (int i = 1; i <= q; i++) {
    if (tmp[i].typ == 'A') printf("%lld\n", tmp[i].ans);
  }
  return 0;
}
