#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
template <typename T>
using v = vector<T>;
struct Fenwick {
  ll n;
  v<ll> arr;
  Fenwick(ll n_) : n(n_), arr(n_) {}
  ll get(ll r) {
    ll res = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) {
      res += arr[r];
    }
    return res;
  }
  void update(ll idx, ll dif) {
    for (; idx < n; idx = idx | (idx + 1)) {
      arr[idx] += dif;
    }
  }
};
struct GarlandNode {
  ll x, y, pleasure;
  GarlandNode(ll x_, ll y_, ll pleasure_) : x(x_), y(y_), pleasure(pleasure_) {}
};
bool compareGarlandNode(const GarlandNode &l, const GarlandNode &r) {
  return (l.x == r.x) ? l.y < r.y : l.x < r.x;
}
struct Query {
  ll x, y, i, corner, sortedi;
  Query(ll x_, ll y_, ll i_, ll corner_)
      : x(x_), y(y_), i(i_), corner(corner_) {}
};
bool compQueryPos(const Query &l, const Query &r) {
  return (l.x == r.x) ? l.y < r.y : l.x < r.x;
}
bool compQueryId(const Query &l, const Query &r) {
  return (l.i == r.i) ? l.corner < r.corner : l.i < r.i;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll n, m, k, x0, y0, x1, y1, numevents;
  string sin;
  cin >> n >> m >> k;
  v<v<GarlandNode>> garlands(k);
  for (ll i = 0; i < k; i++) {
    ll len, pleasure;
    cin >> len;
    for (ll j = 0; j < len; j++) {
      cin >> x0 >> y0 >> pleasure, x0--, y0--;
      garlands[i].emplace_back(x0, y0, pleasure);
    }
    sort(garlands[i].begin(), garlands[i].end(), compareGarlandNode);
  }
  v<Query> qs;
  v<pll> toggles;
  cin >> numevents;
  for (ll i = 0; i < numevents; i++) {
    cin >> sin;
    if (sin == "ASK") {
      cin >> x0 >> y0 >> x1 >> y1, x0--, y0--, x1--, y1--;
      qs.emplace_back(x1, y1, i, 0);
      qs.emplace_back(x1, y0 - 1, i, 1);
      qs.emplace_back(x0 - 1, y1, i, 2);
      qs.emplace_back(x0 - 1, y0 - 1, i, 3);
    } else {
      ll garland;
      cin >> garland, garland--;
      toggles.emplace_back(i, garland);
    }
  }
  sort(qs.begin(), qs.end(), compQueryPos);
  for (ll i = 0; i < (ll)qs.size(); i++) {
    qs[i].sortedi = i;
  }
  v<v<ll>> gqres(k, v<ll>(qs.size()));
  for (ll i = 0; i < k; i++) {
    Fenwick tree(m);
    v<GarlandNode> curg = garlands[i];
    ll nid = 0;
    for (ll j = 0; j < (ll)qs.size(); j++) {
      const auto &q = qs[j];
      for (; nid < (ll)curg.size() && curg[nid].x <= q.x; nid++) {
        tree.update(curg[nid].y, curg[nid].pleasure);
      }
      gqres[i][j] = tree.get(q.y);
    }
  }
  sort(qs.begin(), qs.end(), compQueryId);
  v<bool> on(k, true);
  ll ti = 0;
  for (ll i = 0; i < (ll)qs.size(); i += 4) {
    const Query &q = qs[i];
    for (; ti < (ll)toggles.size() && toggles[ti].first <= q.i; ti++) {
      on[toggles[ti].second] = !on[toggles[ti].second];
    }
    ll res = 0;
    for (ll j = 0; j < k; j++) {
      if (on[j]) {
        res += gqres[j][qs[i].sortedi] - gqres[j][qs[i + 1].sortedi] -
               gqres[j][qs[i + 2].sortedi] + gqres[j][qs[i + 3].sortedi];
      }
    }
    cout << res << "\n";
  }
  return 0;
}
