#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto& x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() {
  cout << endl;
  exit(0);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
template <typename Head, typename... Tail>
void show(Head H, Tail... T) {
  cout << H << " ";
  show(T...);
}
template <typename Head, typename... Tail>
void pret(Head H, Tail... T) {
  cout << H << " ";
  pret(T...);
}
const int MOD = 998244353;
const int N = 200000 + 10;
int t[4 * N][33];
int takkuva[4 * N][33];
int b[N][33];
int a[N][6];
void build(int temp, int v, int tl, int tr) {
  if (tl == tr) {
    t[v][temp] = b[tl][temp];
    takkuva[v][temp] = b[tl][temp];
  } else {
    int tm = (tl + tr) / 2;
    build(temp, v * 2, tl, tm);
    build(temp, v * 2 + 1, tm + 1, tr);
    t[v][temp] = max(t[v * 2][temp], t[v * 2 + 1][temp]);
    takkuva[v][temp] = min(takkuva[v * 2][temp], takkuva[v * 2 + 1][temp]);
  }
}
int maximum(int temp, int v, int tl, int tr, int l, int r) {
  if (l > r) return 0 - 1e9;
  if (l == tl && r == tr) {
    return t[v][temp];
  }
  int tm = (tl + tr) / 2;
  return max(maximum(temp, v * 2, tl, tm, l, min(r, tm)),
             maximum(temp, v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
int minimum(int temp, int v, int tl, int tr, int l, int r) {
  if (l > r) return 1e9;
  if (l == tl && r == tr) {
    return takkuva[v][temp];
  }
  int tm = (tl + tr) / 2;
  return min(minimum(temp, v * 2, tl, tm, l, min(r, tm)),
             minimum(temp, v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void update(int temp, int v, int tl, int tr, int pos, int new_val) {
  if (tl == tr) {
    t[v][temp] = new_val;
    takkuva[v][temp] = new_val;
  } else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(temp, v * 2, tl, tm, pos, new_val);
    else
      update(temp, v * 2 + 1, tm + 1, tr, pos, new_val);
    t[v][temp] = max(t[v * 2][temp], t[v * 2 + 1][temp]);
    takkuva[v][temp] = min(takkuva[v * 2][temp], takkuva[v * 2 + 1][temp]);
  }
}
int n, k;
int f(int id, int temp) {
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    if ((temp & (1 << i)))
      ans += a[id][i];
    else
      ans -= a[id][i];
  }
  return ans;
}
int32_t main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < k; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < (1 << k); ++i) {
    for (int j = 1; j <= n; j++) {
      b[j][i] = f(j, i);
    }
  }
  for (int i = 0; i < (1 << k); ++i) {
    build(i, 1, 1, n);
  }
  int q;
  cin >> q;
  while (q--) {
    int tt;
    scanf("%d", &tt);
    if (tt == 1) {
      int id;
      scanf("%d", &id);
      for (int j = 0; j < k; ++j) {
        scanf("%d", &a[id][j]);
      }
      for (int j = 0; j < (1 << k); ++j) {
        b[id][j] = f(id, j);
        update(j, 1, 1, n, id, b[id][j]);
      }
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      int ans = 0;
      for (int i = 0; i < (1 << k); ++i) {
        int myax = maximum(i, 1, 1, n, l, r);
        int myin = minimum(i, 1, 1, n, l, r);
        ans = max(ans, myax - myin);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
