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>
#pragma O3
using namespace std;
int n, k, q, sz, tp, a[500000][15], b[15], x, l, r, ans;
int get(int a[], int msk) {
  int res = 0;
  for (int i = 0; i < k; i++) {
    if (msk & (1 << i))
      res += a[i];
    else
      res -= a[i];
  }
  return res;
}
struct segtree {
  int tree[500000];
  void build(int l, int r, int node, int msk) {
    if (l == r) {
      if (l <= n)
        tree[node] = get(a[l], msk);
      else
        tree[node] = -1e9;
      return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, node << 1, msk);
    build(mid + 1, r, (node << 1) | 1, msk);
    tree[node] = max(tree[node << 1], tree[(node << 1) | 1]);
  }
  void update(int x, int y) {
    int pos = sz - 1 + x;
    tree[pos] = y;
    pos >>= 1;
    while (pos >= 1) {
      tree[pos] = max(tree[pos << 1], tree[(pos << 1) | 1]);
      pos >>= 1;
    }
  }
  int query(int beg, int en, int l, int r, int node) {
    if (l > en || r < beg) return -1e9;
    if (l >= beg && r <= en) return tree[node];
    int mid = (l + r) >> 1;
    return max(query(beg, en, l, mid, node << 1),
               query(beg, en, mid + 1, r, (node << 1) | 1));
  }
} st[50];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < k; j++) scanf("%d", &a[i][j]);
  sz = 1;
  while (sz < n) sz *= 2;
  for (int i = 0; i < (1 << k); i++) st[i].build(1, sz, 1, i);
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &tp);
    if (tp == 1) {
      scanf("%d", &x);
      for (int i = 0; i < k; i++) scanf("%d", &b[i]);
      for (int i = 0; i < (1 << k); i++) st[i].update(x, get(b, i));
    } else {
      ans = 0;
      scanf("%d%d", &l, &r);
      for (int i = 0; i < (1 << (k - 1)); i++) {
        ans = max(ans, st[i].query(l, r, 1, sz, 1) +
                           st[(1 << k) - 1 - i].query(l, r, 1, sz, 1));
      }
      printf("%d\n", ans);
    }
  }
}
