#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T BM(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T mdINV(T a, T M) {
  return BM(a, M - 2, M);
}
template <class T>
inline T PW(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
template <class T>
string NTS(T Number) {
  stringstream ss;
  ss << Number;
  return ss.str();
}
template <class T>
T stringtonumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
}
template <class T>
bool ISLEFT(T a, T b, T c) {
  if (((a.first.first - b.first.first) * (b.second.second - c.second.second) -
       (b.first.first - c.first.first) * (a.second.second - b.second.second)) <
      0.0)
    return 1;
  else
    return 0;
}
long long int tr[2003][2003];
void update(int first, int second, long long int val) {
  while (first <= 2000) {
    int yy1 = second;
    while (yy1 <= 2000) {
      tr[first][yy1] += val;
      yy1 += yy1 & -yy1;
    }
    first += first & -first;
  }
}
long long int res(int first, int second) {
  long long int sum = 0;
  while (first > 0) {
    int yy1 = second;
    while (yy1 > 0) {
      sum += tr[first][yy1];
      yy1 -= yy1 & -yy1;
    }
    first -= first & -first;
  }
  return sum;
}
pair<pair<int, int>, long long int> gar[2002][2002];
long long int ans[2002][2002];
bool batti[300000 + 2];
int main() {
  int r, c;
  scanf("%d%d", &r, &c);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &gar[i][0].first.first);
    for (int j = 1; j <= gar[i][0].first.first; j++) {
      scanf("%d%d", &gar[i][j].first.first, &gar[i][j].first.second);
      scanf("%lld", &gar[i][j].second);
    }
  }
  int qq;
  scanf("%d", &qq);
  int vq[qq + 2][5];
  char s[10];
  int tq[qq + 2][5];
  int l = 0;
  for (int i = 1; i <= qq; i++) {
    scanf("%s", s);
    if (s[0] == 'A') {
      vq[i][0] = 1;
      for (int j = 1; j <= 4; j++) scanf("%d", &vq[i][j]);
      ++l;
      for (int j = 1; j <= 4; j++) tq[l][j] = vq[i][j];
    } else {
      scanf("%d", &vq[i][1]);
      vq[i][0] = 0;
    }
  }
  for (int i = 1; i <= q; i++) {
    for (int j = 1; j <= gar[i][0].first.first; j++) {
      update(gar[i][j].first.first, gar[i][j].first.second, gar[i][j].second);
    }
    for (int j = 1; j <= l; j++) {
      ans[j][i] = res(tq[j][3], tq[j][4]);
      ans[j][i] += res(tq[j][1] - 1, tq[j][2] - 1);
      ans[j][i] -= res(tq[j][1] - 1, tq[j][4]);
      ans[j][i] -= res(tq[j][3], tq[j][2] - 1);
    }
    for (int j = 1; j <= gar[i][0].first.first; j++) {
      update(gar[i][j].first.first, gar[i][j].first.second, -gar[i][j].second);
    }
  }
  int cnt = 0;
  for (int i = 1; i <= qq; i++) {
    if (vq[i][0] == 0) {
      batti[vq[i][1]] ^= 1;
    } else {
      cnt++;
      long long int re = 0;
      for (int j = 1; j <= q; j++) {
        if (batti[j] == 0) re += ans[cnt][j];
      }
      printf("%lld", re), printf("\n");
    }
  }
  return 0;
}
