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, q;
char cmd[123];
pair<int, int> segTree[40][4 * 200005];
int f(int in, int x[]) {
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (in % 2 == 0)
      ans += x[i];
    else
      ans -= x[i];
    in /= 2;
  }
  return ans;
}
void update(int node, int st, int ed, int p, int x[]) {
  if (ed < p || st > p) return;
  if (st == p && ed == p) {
    for (int i = 0; i < 32; i++) {
      segTree[i][node] = pair<int, int>(f(i, x), f(i, x));
    }
    return;
  }
  int lft = 2 * node, rgt = 2 * node + 1, md = (st + ed) / 2;
  update(lft, st, md, p, x);
  update(rgt, md + 1, ed, p, x);
  for (int i = 0; i < 32; i++)
    segTree[i][node] = {max(segTree[i][lft].first, segTree[i][rgt].first),
                        min(segTree[i][lft].second, segTree[i][rgt].second)};
}
pair<int, int> query(int in, int node, int st, int ed, int l, int r) {
  if (ed < l || st > r) return {INT_MIN, INT_MAX};
  if (st >= l && ed <= r) return segTree[in][node];
  int lft = 2 * node, rgt = 2 * node + 1, md = (st + ed) / 2;
  pair<int, int> p, q, ans;
  p = query(in, lft, st, md, l, r);
  q = query(in, rgt, md + 1, ed, l, r);
  ans = {max(p.first, q.first), min(p.second, q.second)};
  return ans;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int in = 0; in < 32; in++)
    for (int i = 0; i < 4 * n; i++)
      segTree[in][i].first = INT_MIN, segTree[in][i].second = INT_MAX;
  for (int i = 1; i <= n; i++) {
    int x[10] = {0};
    for (int i = 0; i < k; i++) scanf("%d", &x[i]);
    update(1, 1, n, i, x);
  }
  scanf("%d", &q);
  while (q--) {
    int t, p, x[10] = {0}, u, v;
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d", &p);
      for (int i = 0; i < k; i++) scanf("%d", &x[i]);
      update(1, 1, n, p, x);
    } else {
      scanf("%d %d", &u, &v);
      int ans = INT_MIN;
      for (int i = 0; i < 32; i++) {
        pair<int, int> temp = query(i, 1, 1, n, u, v);
        ans = max(ans, temp.first - temp.second);
      }
      printf("%d\n", ans);
    }
  }
}
