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 MAXN = 200001;
const long long K = 5;
const long long INF = 1e16 + 7;
long long n, k, q;
long long a[MAXN][K];
long long tree[MAXN << 2][1 << K];
void upd(long long v, long long tl, long long tr, long long p) {
  if (tl == tr) {
    for (long long i = 0; i < k; ++i) {
      cin >> a[tl][i];
    }
    for (long long mask = 0; mask < (1 << k); ++mask) {
      long long cost = 0;
      for (long long i = 0; i < k; ++i) {
        if ((mask >> i) & 1) {
          cost += a[tl][i];
        } else {
          cost -= a[tl][i];
        }
      }
      tree[v][mask] = cost;
    }
    return;
  }
  long long tm = (tl + tr) >> 1;
  if (p <= tm) {
    upd(v * 2 + 1, tl, tm, p);
  } else {
    upd(v * 2 + 2, tm + 1, tr, p);
  }
  for (long long mask = 0; mask < (1 << k); ++mask) {
    tree[v][mask] = max(tree[v * 2 + 1][mask], tree[v * 2 + 2][mask]);
  }
}
long long getmax(long long v, long long tl, long long tr, long long l,
                 long long r, long long mask) {
  if (tr < l || r < tl) {
    return -INF;
  }
  if (l <= tl && tr <= r) {
    return tree[v][mask];
  }
  long long tm = (tl + tr) >> 1;
  return max(getmax(v * 2 + 1, tl, tm, l, r, mask),
             getmax(v * 2 + 2, tm + 1, tr, l, r, mask));
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 0; i < (MAXN << 2); ++i) {
    for (long long mask = 0; mask < (1 << K); ++mask) {
      tree[i][mask] = -INF;
    }
  }
  cin >> n >> k;
  for (long long i = 0; i < n; ++i) {
    upd(0, 0, n - 1, i);
  }
  cin >> q;
  for (long long i = 0; i < q; ++i) {
    long long t;
    cin >> t;
    if (t == 1) {
      long long p;
      cin >> p;
      --p;
      upd(0, 0, n - 1, p);
    } else {
      long long l, r;
      cin >> l >> r;
      --l;
      --r;
      long long ans = -INF;
      for (long long mask = 0; mask < (1 << (k - 1)); ++mask) {
        ans = max(ans, getmax(0, 0, n - 1, l, r, mask) +
                           getmax(0, 0, n - 1, l, r, mask ^ ((1 << k) - 1)));
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
