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;
const long long int sz = 2e5 + 100;
const long long int MAX = 1e18 + 100;
long long int tree[sz * 4][32];
long long int ara[sz][6], d, n;
void update(long long int l, long long int r, long long int tar,
            long long int pos) {
  if (l == r && l == tar) {
    for (long long int i = 0; i < (1 << d); i++) {
      long long int sum = 0;
      for (long long int j = 0; j < d; j++) {
        if ((i & (1 << j)) > 0)
          sum += ara[l][j];
        else
          sum += (0 - ara[l][j]);
      }
      tree[pos][i] = sum;
    }
    return;
  }
  long long int mid = (l + r) / 2;
  long long int lc = pos * 2 + 1;
  long long int rc = lc + 1;
  if (tar <= mid)
    update(l, mid, tar, lc);
  else
    update(mid + 1, r, tar, rc);
  for (long long int i = 0; i < (1 << d); i++) {
    tree[pos][i] = max(tree[lc][i], tree[rc][i]);
  }
}
long long int query(long long int l, long long int r, long long int p,
                    long long int q, long long int pos, long long int id) {
  if (r < p || q < l) {
    return -MAX;
  } else if (p <= l && r <= q)
    return tree[pos][id];
  long long int mid = (l + r) / 2;
  long long int lc = pos * 2 + 1;
  long long int rc = lc + 1;
  return max(query(l, mid, p, q, lc, id), query(mid + 1, r, p, q, rc, id));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, i, j, k, q, p, x, y, ct, ct1, m, l, r, x1, y1, h, sum1,
      in, z, mid, mx;
  char ch;
  string str1, str2, str;
  bool bl, bl1;
  int t, cs = 1;
  scanf("%lld %lld", &n, &d);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) scanf("%lld", &ara[i][j]);
    update(0, n - 1, i, 0);
  }
  scanf("%lld", &m);
  while (m--) {
    int mark;
    scanf("%d", &mark);
    if (mark == 1) {
      long long int id;
      scanf("%lld", &id);
      --id;
      for (int i = 0; i < d; i++) scanf("%lld", &ara[id][i]);
      update(0, n - 1, id, 0);
    } else {
      scanf("%lld %lld", &p, &q);
      --p, --q;
      long long int ans = 0;
      for (long long int i = 0; i < (1 << (d - 1)); i++) {
        long long int rev = i ^ ((1 << d) - 1);
        long long int le = query(0, n - 1, p, q, 0, i);
        long long int be = query(0, n - 1, p, q, 0, rev);
        ans = max(ans, (le + be));
      }
      printf("%lld\n", ans);
    }
  }
}
