#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
template <class T>
auto dud(T *x) -> decltype(cerr << *x, 0);
template <class T>
char dud(...);
struct debug {
  template <class T>
  debug &operator<<(const T &) {
    return *this;
  }
};
const int N = 2e5 + 5;
const int inf = 1e8;
const int MK = (1 << 5);
array<int, 5> a[N];
int n, k, q;
struct Space {
  array<int, MK> mx, mn;
  int dist;
  Space() {
    for (auto i = (0) - ((0) > (MK)); i != MK - ((0) > (MK));
         i += 1 - 2 * ((0) > (MK)))
      mx[i] = -inf, mn[i] = inf;
    dist = 0;
  }
  Space(array<int, 5> a) {
    for (auto i = (0) - ((0) > (MK)); i != MK - ((0) > (MK));
         i += 1 - 2 * ((0) > (MK))) {
      int tot = 0;
      for (auto j = (0) - ((0) > (k)); j != k - ((0) > (k));
           j += 1 - 2 * ((0) > (k)))
        tot += (i & (1 << j) ? -a[j] : a[j]);
      mx[i] = mn[i] = tot;
    }
    dist = 0;
  }
};
Space operator+(Space a, Space b) {
  Space c;
  c.dist = max(a.dist, b.dist);
  for (auto i = (0) - ((0) > (MK)); i != MK - ((0) > (MK));
       i += 1 - 2 * ((0) > (MK))) {
    c.dist = max(c.dist, a.mx[i] - b.mn[i]);
    c.dist = max(c.dist, b.mx[i] - a.mn[i]);
    c.mx[i] = max(a.mx[i], b.mx[i]);
    c.mn[i] = min(a.mn[i], b.mn[i]);
  }
  return c;
}
struct Seg {
  int l, r;
  Space kd;
  Seg *L, *R;
  Seg(int l, int r) : l(l), r(r), L(0), R(0) {}
  void pull() { kd = L->kd + R->kd; }
  void build() {
    if (l == r) {
      kd = Space(a[l]);
      return;
    }
    int m = (l + r) / 2;
    (L = new Seg(l, m))->build();
    (R = new Seg(m + 1, r))->build();
    pull();
  }
  void update(int p) {
    if (l == r) {
      kd = Space(a[p]);
      return;
    }
    int m = (l + r) / 2;
    if (p <= m)
      L->update(p);
    else
      R->update(p);
    pull();
  }
  Space query(int ll, int rr) {
    if (rr < l || r < ll) return Space();
    if (ll <= l && r <= rr) return kd;
    return L->query(ll, rr) + R->query(ll, rr);
  }
};
Seg *tree;
int main() {
  cin.tie(0)->sync_with_stdio(0), cout.tie(0);
  cin >> n >> k;
  for (auto i = (1) - ((1) > (n + 1)); i != n + 1 - ((1) > (n + 1));
       i += 1 - 2 * ((1) > (n + 1)))
    for (auto j = (0) - ((0) > (k)); j != k - ((0) > (k));
         j += 1 - 2 * ((0) > (k)))
      cin >> a[i][j];
  (tree = new Seg(1, n))->build();
  cin >> q;
  int t, i, l, r;
  while (q--) {
    cin >> t;
    if (t == 1) {
      cin >> i;
      for (auto j = (0) - ((0) > (k)); j != k - ((0) > (k));
           j += 1 - 2 * ((0) > (k)))
        cin >> a[i][j];
      tree->update(i);
    } else {
      cin >> l >> r;
      cout << tree->query(l, r).dist << '\n';
    }
  }
  return 0;
}
