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 a[200005][32];
struct node {
  int a[32], b[32];
  int mx;
};
node st[4 * 200000 + 5];
node merge(node l, node r) {
  if (l.mx == -1) return r;
  if (r.mx == -1) return l;
  node res;
  res.mx = max(l.mx, r.mx);
  for (int i = 0; i < 32; i++) {
    int j = 31 ^ i;
    res.mx = max(res.mx, l.a[i] + r.a[j]);
    res.a[i] = max(l.a[i], r.a[i]);
    res.b[i] = min(l.b[i], r.b[i]);
  }
  return res;
}
void build(int n, int s, int e) {
  if (s == e) {
    node x;
    for (int i = 0; i < (1 << 5); i++) {
      int res = 0;
      for (int j = 0; j < 5; j++) {
        if ((i >> j) & 1)
          res += a[s][j];
        else
          res -= a[s][j];
      }
      x.a[i] = x.b[i] = res;
      x.mx = 0;
    }
    st[n] = x;
  } else {
    int mid = (s + e) / 2;
    build(n + n, s, mid);
    build(n + n + 1, mid + 1, e);
    st[n] = merge(st[n + n], st[n + n + 1]);
  }
}
void update(int n, int s, int e, int idx) {
  if (s == e) {
    node x;
    for (int i = 0; i < (1 << 5); i++) {
      int res = 0;
      for (int j = 0; j < 5; j++) {
        if ((i >> j) & 1)
          res += a[s][j];
        else
          res -= a[s][j];
      }
      x.a[i] = x.b[i] = res;
      x.mx = 0;
    }
    st[n] = x;
  } else {
    int mid = (s + e) / 2;
    if (idx <= mid)
      update(n + n, s, mid, idx);
    else
      update(n + n + 1, mid + 1, e, idx);
    st[n] = merge(st[n + n], st[n + n + 1]);
  }
}
node query(int n, int s, int e, int l, int r) {
  if (s > r || l > e) {
    node x;
    x.mx = -1;
    return x;
  }
  if (l <= s && e <= r) return st[n];
  int mid = (s + e) / 2;
  node p1 = query(n + n, s, mid, l, r);
  node p2 = query(n + n + 1, mid + 1, e, l, r);
  return merge(p1, p2);
}
int main() {
  node x;
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      scanf("%d", &a[i][j]);
      a[i][j] += 1000000;
    }
  }
  build(1, 1, n);
  int q;
  scanf("%d", &q);
  while (q--) {
    int t, i;
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d", &i);
      for (int j = 0; j < k; j++) {
        scanf("%d", &a[i][j]);
        a[i][j] += 1000000;
      }
      update(1, 1, n, i);
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      printf("%d\n", query(1, 1, n, l, r).mx);
    }
  }
}
