#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
const int N = 2e5 + 10;
int seg[1 << 5][2 * N];
int v[N][5];
int n, k;
void build() {
  for (int mask = 0; mask < 1 << k; mask++) {
    int *s = seg[mask];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < k; j++) {
        if ((1 << j) & mask)
          s[i + n] += v[i][j];
        else
          s[i + n] -= v[i][j];
      }
    }
    for (int i = n - 1; i >= 1; i--)
      for (int id = 0; id < k; id++) s[i] = max(s[i << 1], s[i << 1 | 1]);
  }
}
int qry(int l, int r, int mask) {
  int *s = seg[mask];
  int ans = -INT_MAX;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = max(s[l++], ans);
    if (r & 1) ans = max(s[--r], ans);
  }
  return ans;
}
int qry(int l, int r) {
  int ans = 0;
  int max_mask = (1 << k) - 1;
  for (int mask = 0; mask < 1 << (k - 1); mask++) {
    ans = max(ans, qry(l, r, mask) + qry(l, r, mask ^ max_mask));
  }
  return ans;
}
void up(int id, vector<int> val) {
  for (int i = 0; i < k; i++) v[id][i] = val[i];
  for (int mask = 0; mask < 1 << k; mask++) {
    int *s = seg[mask];
    s[id + n] = 0;
    for (int i = 0; i < k; i++) {
      if ((1 << i) & mask)
        s[id + n] += v[id][i];
      else
        s[id + n] -= v[id][i];
    }
    int pos = id;
    for (pos += n; pos > 1; pos >>= 1) s[pos >> 1] = max(s[pos], s[pos ^ 1]);
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) scanf("%d", v[i] + j);
  }
  build();
  int q;
  scanf("%d", &q);
  for (int qq = 0; qq < q; qq++) {
    char t;
    scanf(" %c", &t);
    if (t == '1') {
      int id;
      scanf("%d", &id);
      vector<int> vv;
      for (int i = 0; i < k; i++) {
        int x;
        scanf("%d", &x);
        vv.push_back(x);
      }
      up(id - 1, vv);
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      printf("%d\n", qry(l, r));
    }
  }
  return 0;
}
