#include <bits/stdc++.h>
using namespace std;
const long long N = 2000 + 5;
struct FenwickTree {
  vector<long long> bit;
  long long n;
  FenwickTree(long long n = N) {
    this->n = n;
    bit.assign(n, 0);
  }
  FenwickTree(vector<long long> a) : FenwickTree(a.size()) {
    for (size_t i = 0; i < a.size(); i++) add(i, a[i]);
  }
  long long sum(long long r) {
    long long ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret += bit[r];
    return ret;
  }
  long long sum(long long l, long long r) { return sum(r) - sum(l - 1); }
  void add(long long idx, long long delta) {
    for (; idx < n; idx = idx | (idx + 1)) bit[idx] += delta;
  }
};
FenwickTree FT[N];
long long cunt[N][N];
vector<pair<pair<long long, long long>, pair<long long, long long>>> G;
vector<pair<long long, long long>> Q;
vector<pair<pair<long long, long long>, pair<long long, long long>>> adj[N];
long long state[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, K;
  cin >> n >> m >> K;
  for (long long i = 1; i <= K; i++) {
    long long len;
    cin >> len;
    while (len--) {
      long long a, b, c;
      cin >> a >> b >> c;
      G.push_back(make_pair(make_pair(a, b), make_pair(c, i)));
    }
  }
  sort(G.begin(), G.end());
  long long kc = 0;
  long long q;
  cin >> q;
  for (long long i = 1; i <= q; i++) {
    string s;
    cin >> s;
    if (s[0] == 'S') {
      long long a;
      cin >> a;
      Q.push_back(make_pair(0, a));
    } else {
      long long x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      kc++;
      Q.push_back(make_pair(1, kc));
      adj[x1 - 1].push_back(make_pair(make_pair(y1, y2), make_pair(kc, -1)));
      adj[x2].push_back(make_pair(make_pair(y1, y2), make_pair(kc, +1)));
    }
  }
  long long at = 0;
  for (long long i = 0; i <= n; i++) {
    while (at < (long long)G.size() and G[at].first.first <= i) {
      FT[G[at].second.second].add(G[at].first.second, G[at].second.first);
      at++;
    }
    for (auto &it : adj[i]) {
      for (long long j = 1; j <= K; j++) {
        cunt[it.second.first][j] +=
            it.second.second * FT[j].sum(it.first.first, it.first.second);
      }
    }
  }
  for (auto &q : Q) {
    if (q.first) {
      long long ans = 0;
      for (long long i = 1; i <= K; i++) {
        if (state[i]) continue;
        ans += cunt[q.second][i];
      }
      cout << ans << "\n";
    } else {
      state[q.second] = 1 - state[q.second];
    }
  }
  return 0;
}
