#include <bits/stdc++.h>
using namespace std;
template <typename T>
T next_int() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return p * x;
}
string next_string() {
  char ch;
  string ans = "";
  do {
    ch = getchar();
  } while (ch <= ' ');
  while (ch >= 'A' && ch <= 'Z') {
    ans += ch;
    ch = getchar();
  }
  return ans;
}
const int max_int = (int)1e9 + 228;
const int max_n = (int)1e6 + 1;
const int mod = (int)1e9 + 7;
long long d[max_n];
int m;
inline void inc(int p, long long c) {
  for (int i = p + 1; i <= m; i += (i & (-i))) d[i] += c;
}
inline long long get(int p) {
  long long ans = 0;
  for (int i = p + 1; i > 0; i -= (i & (-i))) ans += d[i];
  return ans;
}
vector<pair<int, int> > kek[2005];
int ok[2005][2005];
int oki[2005];
int x[max_n], y[max_n], type[max_n], _x[max_n], _y[max_n], p[max_n];
long long ans[max_n];
int main() {
  int n = next_int<int>();
  m = next_int<int>();
  int k = next_int<int>();
  bool OK = (n == 2000 && m == 2000 && k == 2000);
  vector<vector<vector<pair<int, int> > > > mda(k);
  for (int i = 0; i < k; i++) {
    mda[i].resize(n);
    int len = next_int<int>();
    while (len--) {
      int x = next_int<int>() - 1;
      int y = next_int<int>() - 1;
      int c = next_int<int>();
      mda[i][x].push_back(make_pair(y, c));
    }
  }
  int q = next_int<int>();
  vector<int> qu;
  int ok_size = 0;
  for (int i = 0; i < k; i++) oki[i] = 1;
  for (int i = 0; i < q; i++) {
    string qwe = next_string();
    type[i] = (qwe == "ASK");
    if (type[i]) {
      x[i] = next_int<int>() - 1;
      y[i] = next_int<int>() - 1;
      _x[i] = next_int<int>() - 1;
      _y[i] = next_int<int>() - 1;
      ans[i] = 0;
      qu.push_back(i);
      for (int i = 0; i < k; i++) ok[ok_size][i] = oki[i];
      ok_size++;
    } else {
      p[i] = next_int<int>() - 1;
      oki[p[i]] = 1 - oki[p[i]];
    }
  }
  for (int I = 0; I < k; I++) {
    for (int i = 0; i < n; i++) kek[i].clear();
    for (int i = 0; i < qu.size(); i++) {
      if (ok[i][I]) {
        int z = qu[i];
        kek[_x[z]].push_back(make_pair(_y[z], z + 1));
        if (x[z] && y[z]) kek[x[z] - 1].push_back(make_pair(y[z] - 1, z + 1));
        if (x[z]) kek[x[z] - 1].push_back(make_pair(_y[z], -(z + 1)));
        if (y[z]) kek[_x[z]].push_back(make_pair(y[z] - 1, -(z + 1)));
      }
    }
    for (int i = 1; i <= m; i++) d[i] = 0;
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < mda[I][j].size(); k++)
        inc(mda[I][j][k].first, mda[I][j][k].second);
      for (int k = 0; k < kek[j].size(); k++) {
        ans[abs(kek[j][k].second) - 1] +=
            ((kek[j][k].second > 0) ? 1 : -1) * get(kek[j][k].first);
      }
    }
  }
  for (int i = 0; i < q; i++)
    if (type[i]) cout << ans[i] << "\n";
}
