#include <bits/stdc++.h>
using namespace std;
int inf = 1e9;
struct obj {
  long long int ans;
  vector<long long int> mini;
  vector<long long int> maxi;
  obj() {
    ans = 0;
    mini = vector<long long int>(32, inf);
    maxi = vector<long long int>(32, -inf);
  }
};
int n, k;
int LIM = 2e5 + 10;
obj combine(obj& a, obj& b) {
  obj ret;
  for (int j = 0; j < (1 << k); j++) {
    ret.mini[j] = min(a.mini[j], b.mini[j]);
    ret.maxi[j] = max(a.maxi[j], b.maxi[j]);
    ret.ans = max(ret.ans, ret.maxi[j] - ret.mini[j]);
  }
  return ret;
}
vector<obj> t(2 * LIM);
void build() {
  for (int i = n - 1; i >= 1; i--) {
    t[i] = combine(t[2 * i], t[2 * i + 1]);
  }
}
obj query(int l, int r) {
  obj ret;
  l = l + n - 1;
  r = r + n - 1;
  while (l <= r) {
    if (l % 2 == 1) {
      ret = combine(ret, t[l]);
      l++;
    }
    if (r % 2 == 0) {
      ret = combine(ret, t[r]);
      r--;
    }
    l = l / 2;
    r = r / 2;
  }
  return ret;
}
void update(int i) {
  vector<long long int> b(k + 1);
  for (int j = 0; j < k; j++) cin >> b[j];
  for (int j = 0; j < (1 << k); j++) {
    int temp = 0;
    for (int l = 0; l < k; l++) temp += ((j & (1 << l)) ? b[l] : -b[l]);
    t[i + n - 1].mini[j] = temp;
    t[i + n - 1].maxi[j] = temp;
    t[i + n - 1].ans = 0;
  }
  i = i + n - 1;
  while (i >= 1) {
    i = i / 2;
    t[i] = combine(t[2 * i], t[2 * i + 1]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  vector<vector<long long int> > arr(n + 1, vector<long long int>(k + 1, 0));
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j < k; j++) cin >> arr[i][j];
    for (long long int j = 0; j < (1 << k); j++) {
      long long int temp = 0;
      for (int l = 0; l < k; l++)
        temp += ((j & (1 << l)) ? arr[i][l] : -arr[i][l]);
      t[i + n - 1].mini[j] = min(t[i + n - 1].mini[j], temp);
      t[i + n - 1].maxi[j] = max(t[i + n - 1].maxi[j], temp);
    }
  }
  build();
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int op;
    cin >> op;
    if (op == 1) {
      int num;
      cin >> num;
      update(num);
    } else {
      int l, r;
      cin >> l >> r;
      cout << query(l, r).ans << endl;
    }
  }
  return 0;
}
