#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int inf = 2e9;
int n, k;
int arr[N][5];
struct PT {
  int v[16];
} p[N];
void init(int i) {
  memset(p[i].v, 0, sizeof p[i].v);
  for (int mask = 0; mask < (1 << (k - 1)); mask++) {
    for (int j = 0; j < k; j++) {
      if (mask >> j & 1)
        p[i].v[mask] -= arr[i][j];
      else
        p[i].v[mask] += arr[i][j];
    }
  }
}
struct SGT {
  int mn[N << 2], mx[N << 2];
  void build(int node, int L, int R, int ID) {
    if (L == R) {
      mn[node] = p[L].v[ID];
      mx[node] = p[L].v[ID];
      return;
    }
    int mid = (L + R) >> 1, lc = node << 1, rc = lc | 1;
    build(lc, L, mid, ID);
    build(rc, mid + 1, R, ID);
    mn[node] = min(mn[lc], mn[rc]);
    mx[node] = max(mx[lc], mx[rc]);
  }
  void update(int node, int L, int R, int ID, int pos) {
    if (L == R) {
      mn[node] = p[L].v[ID];
      mx[node] = p[L].v[ID];
      return;
    }
    int mid = (L + R) >> 1, lc = node << 1, rc = lc | 1;
    if (pos <= mid)
      update(lc, L, mid, ID, pos);
    else
      update(rc, mid + 1, R, ID, pos);
    mn[node] = min(mn[lc], mn[rc]);
    mx[node] = max(mx[lc], mx[rc]);
  }
  int getMin(int node, int L, int R, int l, int r) {
    if (r < L || R < l) return inf;
    if (l <= L && R <= r) return mn[node];
    int mid = (L + R) >> 1, lc = node << 1, rc = lc | 1;
    int x = getMin(lc, L, mid, l, r);
    int y = getMin(rc, mid + 1, R, l, r);
    if (x == inf) return y;
    if (y == inf) return x;
    return min(x, y);
  }
  int getMax(int node, int L, int R, int l, int r) {
    if (r < L || R < l) return inf;
    if (l <= L && R <= r) return mx[node];
    int mid = (L + R) >> 1, lc = node << 1, rc = lc | 1;
    int x = getMax(lc, L, mid, l, r);
    int y = getMax(rc, mid + 1, R, l, r);
    if (x == inf) return y;
    if (y == inf) return x;
    return max(x, y);
  }
} ds[16];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) scanf("%d", &arr[i][j]);
    init(i);
  }
  for (int i = 0; i < (1 << (k - 1)); i++) ds[i].build(1, 0, n - 1, i);
  int q;
  scanf("%d", &q);
  while (q--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int idx;
      scanf("%d", &idx);
      idx--;
      for (int i = 0; i < k; i++) scanf("%d", &arr[idx][i]);
      init(idx);
      for (int i = 0; i < (1 << (k - 1)); i++)
        ds[i].update(1, 0, n - 1, i, idx);
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      l--;
      r--;
      int ans = 0;
      for (int i = 0; i < (1 << (k - 1)); i++) {
        ans = max(ans, ds[i].getMax(1, 0, n - 1, l, r) -
                           ds[i].getMin(1, 0, n - 1, l, r));
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
