#include <bits/stdc++.h>
using namespace std;
int s1[32][800008];
int s2[32][800008];
int arr[32][200008];
void build(int index, int l, int r, int typ) {
  if (l == r) {
    s1[typ][index] = arr[typ][l];
    s2[typ][index] = arr[typ][l];
    return;
  }
  int left = (2 * index) + 1;
  int right = (2 * index) + 2;
  int mid = (l + r) / 2;
  build(left, l, mid, typ);
  build(right, mid + 1, r, typ);
  s1[typ][index] = max(s1[typ][left], s1[typ][right]);
  s2[typ][index] = min(s2[typ][left], s2[typ][right]);
  return;
}
void update(int index, int l, int r, int typ, int x, int y) {
  if (r < x || y < l || r < l) {
    return;
  }
  if (x <= l && r <= y) {
    s1[typ][index] = arr[typ][x];
    s2[typ][index] = arr[typ][x];
    return;
  }
  int left = (2 * index) + 1;
  int right = (2 * index) + 2;
  int mid = (l + r) / 2;
  update(left, l, mid, typ, x, y);
  update(right, mid + 1, r, typ, x, y);
  s1[typ][index] = max(s1[typ][left], s1[typ][right]);
  s2[typ][index] = min(s2[typ][left], s2[typ][right]);
  return;
}
int query(int index, int l, int r, int typ, int x, int y, int val) {
  if (r < x || y < l || r < l) {
    if (val == 2)
      return -100000000;
    else
      return 100000000;
  }
  if (x <= l && r <= y) {
    if (val == 2)
      return s1[typ][index];
    else
      return s2[typ][index];
  }
  int left = (2 * index) + 1;
  int right = (2 * index) + 2;
  int mid = (l + r) / 2;
  int a = query(left, l, mid, typ, x, y, val);
  int b = query(right, mid + 1, r, typ, x, y, val);
  if (val == 2)
    return max(a, b);
  else
    return min(a, b);
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, k, i, j, l, r;
  scanf("%d%d", &n, &k);
  int brr[n][k];
  for (i = 0; i < n; i++) {
    for (j = 0; j < k; j++) {
      scanf("%d", &brr[i][j]);
    }
  }
  l = (1 << (k - 1));
  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      int su = 0;
      for (int m = 0; m < k; m++) {
        if (j & (1 << m))
          su = su - brr[i][m];
        else
          su = su + brr[i][m];
      }
      arr[j][i] = su;
    }
  }
  for (j = 0; j < l; j++) {
    build(0, 0, n - 1, j);
  }
  int q, index;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &i);
    if (i == 1) {
      scanf("%d", &index);
      index--;
      for (j = 0; j < k; j++) scanf("%d", &brr[index][j]);
      for (j = 0; j < l; j++) {
        int su = 0;
        for (int m = 0; m < k; m++) {
          if (j & (1 << m))
            su = su - brr[index][m];
          else
            su = su + brr[index][m];
        }
        arr[j][index] = su;
      }
      for (j = 0; j < l; j++) update(0, 0, n - 1, j, index, index);
    } else {
      int x, y;
      scanf("%d%d", &x, &y);
      x--;
      y--;
      int ans = -100000000;
      for (j = 0; j < l; j++) {
        int ma = query(0, 0, n - 1, j, x, y, 2);
        int mi = query(0, 0, n - 1, j, x, y, 1);
        ans = max(ans, ma - mi);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
