You are given an array a of n points in k-dimensional space. Let the distance between two points a_x and a_y be ∑ _{i = 1}^{k} |a_{x, i} - a_{y, i}| (it is also known as Manhattan distance).

You have to process q queries of the following two types:

  * 1 i b_1 b_2 ... b_k — set i-th element of a to the point (b_1, b_2, ..., b_k);
  * 2 l r — find the maximum distance between two points a_i and a_j, where l ≤ i, j ≤ r.

Input

The first line contains two numbers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 5) — the number of elements in a and the number of dimensions of the space, respectively.

Then n lines follow, each containing k integers a_{i, 1}, a_{i, 2}, ..., a_{i, k} (-10^6 ≤ a_{i, j} ≤ 10^6) — the coordinates of i-th point.

The next line contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.

Then q lines follow, each denoting a query. There are two types of queries:

  * 1 i b_1 b_2 ... b_k (1 ≤ i ≤ n, -10^6 ≤ b_j ≤ 10^6) — set i-th element of a to the point (b_1, b_2, ..., b_k);
  * 2 l r (1 ≤ l ≤ r ≤ n) — find the maximum distance between two points a_i and a_j, where l ≤ i, j ≤ r.



There is at least one query of the second type.

Output

Print the answer for each query of the second type.

Example

Input


5 2
1 2
2 3
3 4
4 5
5 6
7
2 1 5
2 1 3
2 3 5
1 5 -1 -2
2 1 5
1 4 -1 -2
2 1 5


Output


8
4
4
12
10
#include <bits/stdc++.h>
using namespace std;
int n, k, x, i, j, t[32][(1 << 19) + 5][2];
vector<int> a[(1 << 19) + 5];
void build(int v, int tl, int tr, int mask) {
  int m = (tl + tr) / 2;
  if (tl == tr) {
    int sm = 0;
    for (int i = 0; i < k; i++) {
      if (mask & (1 << i))
        sm += a[tl][i];
      else
        sm -= a[tl][i];
    }
    t[mask][v][0] = t[mask][v][1] = sm;
    return;
  }
  build(v * 2, tl, m, mask);
  build(v * 2 + 1, m + 1, tr, mask);
  t[mask][v][0] = max(t[mask][v * 2][0], t[mask][v * 2 + 1][0]);
  t[mask][v][1] = min(t[mask][v * 2][1], t[mask][v * 2 + 1][1]);
}
int get(int v, int tl, int tr, int l, int r, int mask, bool flag) {
  int m = (tl + tr) / 2;
  if (l > r) return (flag) ? 2000000007LL : -2000000007LL;
  if (tl == l && tr == r) return t[mask][v][flag];
  int res1 = get(v * 2, tl, m, l, min(r, m), mask, flag);
  int res2 = get(v * 2 + 1, m + 1, tr, max(l, m + 1), r, mask, flag);
  if (!flag)
    return max(res1, res2);
  else
    return min(res1, res2);
}
void upd(int v, int tl, int tr, int pos, int value, int mask) {
  int m = (tl + tr) / 2;
  if (tl == tr) {
    t[mask][v][0] = t[mask][v][1] = value;
    return;
  }
  if (pos <= m)
    upd(v * 2, tl, m, pos, value, mask);
  else
    upd(v * 2 + 1, m + 1, tr, pos, value, mask);
  t[mask][v][0] = max(t[mask][v * 2][0], t[mask][v * 2 + 1][0]);
  t[mask][v][1] = min(t[mask][v * 2][1], t[mask][v * 2 + 1][1]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    for (j = 0; j < k; j++) {
      scanf("%d", &x);
      a[i].push_back(x);
    }
  }
  int q, l, r, pos, type;
  scanf("%d", &q);
  for (i = 0; i < (1 << (k - 1)); i++) build(1, 0, n - 1, i);
  while (q--) {
    scanf("%d", &type);
    if (type == 2) {
      scanf("%d%d", &l, &r);
      l--;
      r--;
      int ans = 0;
      for (i = 0; i < (1 << (k - 1)); i++)
        ans = max(ans,
                  get(1, 0, n - 1, l, r, i, 0) - get(1, 0, n - 1, l, r, i, 1));
      printf("%d\n", ans);
    } else {
      scanf("%d", &pos);
      pos--;
      vector<int> v;
      for (i = 0; i < k; i++) {
        scanf("%d", &x);
        v.push_back(x);
      }
      for (i = 0; i < (1 << (k - 1)); i++) {
        int sm = 0;
        for (j = 0; j < k; j++) {
          if (i & (1 << j))
            sm += v[j];
          else
            sm -= v[j];
        }
        upd(1, 0, n - 1, pos, sm, i);
      }
    }
  }
  return 0;
}
