#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long Hashimoto = 0;
  bool Kanna = 1;
  char I_Love = getchar();
  while (I_Love < '0' || I_Love > '9') {
    if (I_Love == '-') Kanna = 0;
    I_Love = getchar();
  }
  while (I_Love >= '0' && I_Love <= '9') {
    Hashimoto = Hashimoto * 10 + I_Love - '0';
    I_Love = getchar();
  }
  return (Kanna ? Hashimoto : -Hashimoto);
}
template <typename T1, typename T2>
inline void Umax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
inline void Umin(T1 &a, T2 b) {
  if (a > b) a = b;
}
int n, m, k;
int st[2222], ed[2222];
int x[4444444], y[4444444], w[4444444];
vector<int> change[2222];
vector<int> ask;
int x1[2222], asdjajdskfl[2222], x2[2222], y2[2222];
long long ans[2222];
long long bit[2222][2222];
void add(int x, int y, int val) {
  while (x < 2222) {
    int k = y;
    while (k < 2222) {
      bit[x][k] += val;
      k += k & -k;
    }
    x += x & -x;
  }
}
long long sum(int x, int y) {
  long long ret = 0;
  while (x > 0) {
    int k = y;
    while (k > 0) {
      ret += bit[x][k];
      k -= k & -k;
    }
    x -= x & -x;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  n = read();
  m = read();
  k = read();
  for (int i = 0; i < (k); ++i) {
    if (i)
      st[i] = ed[i - 1];
    else
      st[i] = 0;
    int len = read();
    ed[i] = st[i] + len;
    for (int j = st[i]; j < (ed[i]); ++j) {
      x[j] = read();
      y[j] = read();
      w[j] = read();
    }
  }
  int q = read();
  for (int FA = 0; FA < (q); ++FA) {
    char s[11];
    scanf("%s", s);
    if (s[0] == 'S') {
      int x = read() - 1;
      change[x].push_back(FA);
    } else {
      x1[ask.size()] = read();
      asdjajdskfl[ask.size()] = read();
      x2[ask.size()] = read();
      y2[ask.size()] = read();
      ask.push_back(FA);
    }
  }
  for (int tot = 0; tot < (k); ++tot) {
    for (int i = st[tot]; i < (ed[tot]); ++i) add(x[i], y[i], w[i]);
    int j = 0;
    bool f = 1;
    for (int i = 0; i < (ask.size()); ++i) {
      while (j < change[tot].size() && change[tot][j] < ask[i]) {
        j++;
        f = !f;
      }
      if (f) {
        ans[i] += sum(x2[i], y2[i]) - sum(x1[i] - 1, y2[i]) -
                  sum(x2[i], asdjajdskfl[i] - 1) +
                  sum(x1[i] - 1, asdjajdskfl[i] - 1);
      }
    }
    for (int i = st[tot]; i < (ed[tot]); ++i) add(x[i], y[i], -w[i]);
  }
  for (int i = 0; i < (ask.size()); ++i) printf("%I64d ", ans[i]);
  return 0;
}
