#include <bits/stdc++.h>
using namespace std;
int n, k, sum, p[200009][7], stt[34][200009], q, t, ind, l, r;
const int M = 1e9 + 7;
class seg_min {
 private:
  pair<int, int> st[200009 + 200009 + 200009 + 200009];

 public:
  void build(int *a, int node = 1, int l = 1, int r = 200009 - 1) {
    if (l > r) return;
    if (l == r)
      st[node] = make_pair(a[l], a[l]);
    else {
      build(a, node + node, l, (l + r >> 1));
      build(a, node + 1 + node, (l + r >> 1) + 1, r);
      int L = node + node;
      int R = L + 1;
      st[node] = make_pair(min(st[L].first, st[R].first),
                           max(st[L].second, st[R].second));
    }
  }
  void update(int x, int v, int node = 1, int l = 1, int r = 200009 - 1) {
    if (l > r or x > r or x < l) return;
    if (l == r)
      st[node] = make_pair(v, v);
    else {
      int L = node << 1;
      int R = L + 1;
      int mid = l + r >> 1;
      update(x, v, L, l, mid);
      update(x, v, R, mid + 1, r);
      st[node] = make_pair(min(st[L].first, st[R].first),
                           max(st[L].second, st[R].second));
    }
  }
  pair<int, int> query(int ql, int qr, int node = 1, int l = 1,
                       int r = 200009 - 1) {
    if (l > r or ql > r or qr < l) return make_pair(INT_MAX, INT_MIN);
    if (l >= ql and r <= qr)
      return st[node];
    else {
      pair<int, int> L = query(ql, qr, node + node, l, (l + r >> 1));
      pair<int, int> R = query(ql, qr, node + 1 + node, (l + r >> 1) + 1, r);
      return make_pair(min(L.first, R.first), max(L.second, R.second));
    }
  }
} st[34];
int32_t main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    for (int ii = 1; ii <= k; ii++) scanf("%d", &p[i][ii]);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << k); j++) {
      sum = 0;
      for (int dim = 1; dim <= k; dim++)
        sum += (((j >> dim - 1) & 1) ? -p[i][dim] : p[i][dim]);
      stt[j][i] = sum;
    }
  for (int i = 0; i < (1 << k); i++) st[i].build(stt[i]);
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d", &ind);
      for (int i = 1; i <= k; i++) scanf("%d", &p[ind][i]);
      for (int i = 0; i < (1 << k); i++) {
        sum = 0;
        for (int j = 1; j <= k; j++)
          sum += (((i >> j - 1) & 1) ? -p[ind][j] : p[ind][j]);
        st[i].update(ind, sum);
      }
    } else {
      scanf("%d%d", &l, &r);
      sum = 0;
      for (int i = 0; i < (1 << k); i++) {
        pair<int, int> ha = st[i].query(l, r);
        sum = max(sum, ha.second - ha.first);
      }
      printf("%d\n", sum);
    }
  }
}
