#include <bits/stdc++.h>
using namespace std;
struct SWAGTREE {
  int values[4 * 200013];
  int values2[4 * 200013];
  void update(int i, int left, int right, int index, int value) {
    if (right < left || right < index || index < left) return;
    if (left == right) {
      if (index == left) {
        values[i] = value;
        values2[i] = -value;
      }
      return;
    }
    int mid = (left + right) / 2;
    update(2 * i, left, mid, index, value);
    update(2 * i + 1, mid + 1, right, index, value);
    values[i] = max(values[2 * i], values[2 * i + 1]);
    values2[i] = max(values2[2 * i], values2[2 * i + 1]);
  }
  pair<int, int> query(int i, int left, int right, int start, int end) {
    if (right < left || right < start || end < left)
      return make_pair(-1000000000, -1000000000);
    if (start <= left && right <= end) {
      return make_pair(values[i], values2[i]);
    }
    int mid = (left + right) / 2;
    pair<int, int> firstHalf = query(2 * i, left, mid, start, end);
    pair<int, int> secondHalf = query(2 * i + 1, mid + 1, right, start, end);
    return make_pair(max(firstHalf.first, secondHalf.first),
                     max(firstHalf.second, secondHalf.second));
  }
} trees[1 << 5];
int n, dimensions;
int values[200013][5];
int main() {
  if (fopen("FILENAME.in", "r")) {
    freopen("FILENAME.in", "r", stdin);
    freopen("FILENAME.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> dimensions;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < dimensions; j++) {
      cin >> values[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (1 << dimensions); j++) {
      int trueValue = 0;
      for (int k = 0; k < dimensions; k++) {
        trueValue += ((j & (1 << k)) ? values[i][k] : -values[i][k]);
      }
      trees[j].update(1, 0, n - 1, i, trueValue);
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int index;
      cin >> index;
      index--;
      for (int i = 0; i < dimensions; i++) {
        cin >> values[index][i];
      }
      for (int j = 0; j < (1 << dimensions); j++) {
        int trueValue = 0;
        for (int k = 0; k < dimensions; k++) {
          trueValue += ((j & (1 << k)) ? values[index][k] : -values[index][k]);
        }
        trees[j].update(1, 0, n - 1, index, trueValue);
      }
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      int answer = 0;
      for (int i = 0; i < (1 << dimensions); i++) {
        pair<int, int> temp = trees[i].query(1, 0, n - 1, l, r);
        answer = max(answer, temp.first + temp.second);
      }
      cout << answer << '\n';
    }
  }
}
