#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
long long add(long long a, long long b) {
  long long ret = a + b;
  if (ret >= 1000000007) ret -= 1000000007;
  return ret;
}
long long subtract(long long a, long long b) {
  long long ret = a - b;
  if (ret < 0) ret += 1000000007;
  return ret;
}
long long mult(long long a, long long b) {
  long long ret = a * b;
  if (ret >= 1000000007) ret %= 1000000007;
  return ret;
}
long long bigmod(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = mult(ret, a);
    b >>= 1;
    a = mult(a, a);
  }
  return ret;
}
long long inverse(long long n) { return bigmod(n, 1000000007 - 2); }
bool base[1000010];
vector<int> primes;
void sieve(int mx) {
  mx += 10;
  int x = sqrt(mx);
  for (int i = 3; i <= x; i += 2)
    if (base[i] == 0)
      for (int j = i * i, k = i << 1; j < mx; j += k) base[j] = 1;
  primes.push_back(2);
  for (int i = 3; i < mx; i += 2)
    if (base[i] == 0) primes.push_back(i);
}
bool checkBit(int n, int i) { return (n & (1 << i)); }
int setBit(int n, int i) { return (n | (1 << i)); }
int resetBit(int n, int i) { return (n & (~(1 << i))); }
int n, m, k, len[2010], x[2010][2010], y[2010][2010], z[2010][2010],
    type[1000010], ask[2010], q[1000010][4], sw[2010];
long long tree[2010 * 2][2010 * 2], calc[2010][2010];
char a[10];
void update(int x, int y, long long v) {
  for (int i = x; i <= n; i += i & -i)
    for (int j = y; j <= m; j += j & -j) tree[i][j] += v;
}
long long query(int x, int y) {
  long long ret = 0;
  for (int i = x; i > 0; i -= i & -i)
    for (int j = y; j > 0; j -= j & -j) ret += tree[i][j];
  return ret;
}
int main() {
  int Q;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; ++i) {
    scanf("%d", &len[i]);
    for (int j = 0; j < len[i]; ++j)
      scanf("%d%d%d", &x[i][j], &y[i][j], &z[i][j]);
  }
  scanf("%d", &Q);
  int tot = 0;
  for (int i = 0; i < Q; ++i) {
    scanf("%s", a);
    if (a[0] == 'A') {
      type[i] = 0;
      for (int j = 0; j < 4; ++j) scanf("%d", &q[i][j]);
      ask[tot++] = i;
    } else {
      type[i] = 1;
      scanf("%d", &q[i][0]);
    }
  }
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j < len[i]; ++j) update(x[i][j], y[i][j], z[i][j]);
    for (int j = 0; j < tot; ++j) {
      int idx = ask[j];
      int x1 = q[idx][0], y1 = q[idx][1], x2 = q[idx][2], y2 = q[idx][3];
      calc[j][i] = query(x2, y2) - query(x2, y1 - 1) - query(x1 - 1, y2) +
                   query(x1 - 1, y1 - 1);
    }
    for (int j = 0; j < len[i]; ++j) update(x[i][j], y[i][j], -z[i][j]);
  }
  for (int i = 1; i <= k; ++i) sw[i] = 1;
  int cnt = 0;
  for (int i = 0; i < Q; ++i) {
    if (type[i] == 1)
      sw[q[i][0]] ^= 1;
    else {
      long long ans = 0;
      for (int j = 1; j <= k; ++j)
        if (sw[j] == 1) ans += calc[cnt][j];
      ++cnt;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
