#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 200001;
const long long K = 5;
const long long INF = 1e16 + 7;
long long n, k, q;
long long a[MAXN][K];
long long tree[MAXN << 2][1 << K];
void upd(long long v, long long tl, long long tr, long long p) {
  if (tl == tr) {
    for (long long i = 0; i < k; ++i) {
      cin >> a[tl][i];
    }
    for (long long mask = 0; mask < (1 << k); ++mask) {
      long long cost = 0;
      for (long long i = 0; i < k; ++i) {
        if ((mask >> i) & 1) {
          cost += a[tl][i];
        } else {
          cost -= a[tl][i];
        }
      }
      tree[v][mask] = cost;
    }
    return;
  }
  long long tm = (tl + tr) >> 1;
  if (p <= tm) {
    upd(v * 2 + 1, tl, tm, p);
  } else {
    upd(v * 2 + 2, tm + 1, tr, p);
  }
  for (long long mask = 0; mask < (1 << k); ++mask) {
    tree[v][mask] = max(tree[v * 2 + 1][mask], tree[v * 2 + 2][mask]);
  }
}
long long getmax(long long v, long long tl, long long tr, long long l,
                 long long r, long long mask) {
  if (tr < l || r < tl) {
    return -INF;
  }
  if (l <= tl && tr <= r) {
    return tree[v][mask];
  }
  long long tm = (tl + tr) >> 1;
  return max(getmax(v * 2 + 1, tl, tm, l, r, mask),
             getmax(v * 2 + 2, tm + 1, tr, l, r, mask));
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 0; i < (MAXN << 2); ++i) {
    for (long long mask = 0; mask < (1 << K); ++mask) {
      tree[i][mask] = -INF;
    }
  }
  cin >> n >> k;
  for (long long i = 0; i < n; ++i) {
    upd(0, 0, n - 1, i);
  }
  cin >> q;
  for (long long i = 0; i < q; ++i) {
    long long t;
    cin >> t;
    if (t == 1) {
      long long p;
      cin >> p;
      --p;
      upd(0, 0, n - 1, p);
    } else {
      long long l, r;
      cin >> l >> r;
      --l;
      --r;
      long long ans = -INF;
      for (long long mask = 0; mask < (1 << (k - 1)); ++mask) {
        ans = max(ans, getmax(0, 0, n - 1, l, r, mask) +
                           getmax(0, 0, n - 1, l, r, mask ^ ((1 << k) - 1)));
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
