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 int N = 3e5 + 100;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
int Lim, k;
struct Segment_Node {
  int lson, rson;
  int Mx[32];
  Segment_Node() {
    lson = rson = 0;
    memset(Mx, 0, sizeof(Mx));
  }
  friend Segment_Node operator+(Segment_Node A, Segment_Node B) {
    Segment_Node ret;
    ret.lson = A.lson;
    ret.rson = B.rson;
    for (int i = 0; i <= Lim; ++i) {
      ret.Mx[i] = max(A.Mx[i], B.Mx[i]);
    }
    return ret;
  }
  void set(int *A, int k) {
    for (int i = 0; i <= Lim; ++i) Mx[i] = 0;
    for (int i = 0; i <= Lim; ++i) {
      int tmp = 0;
      for (int j = 0; j < k; ++j) {
        if (i & (1 << j)) {
          tmp += A[j];
        } else
          tmp -= A[j];
      }
      Mx[i] = tmp;
    }
  }
} T[N << 2];
int a[N][5];
void Build(int p, int l, int r) {
  T[p].lson = l;
  T[p].rson = r;
  if (l == r) {
    T[p].set(a[l], k);
    return;
  }
  int mid = (l + r) >> 1;
  Build((p << 1), l, mid);
  Build((p << 1 | 1), mid + 1, r);
  T[p] = T[(p << 1)] + T[(p << 1 | 1)];
}
void Update(int p, int pos) {
  if (T[p].lson == T[p].rson) {
    T[p].set(a[T[p].lson], k);
    return;
  }
  int mid = (T[p].lson + T[p].rson) >> 1;
  if (pos <= mid)
    Update((p << 1), pos);
  else
    Update((p << 1 | 1), pos);
  T[p] = T[(p << 1)] + T[(p << 1 | 1)];
}
Segment_Node Query(int p, int l, int r) {
  if (l <= T[p].lson && T[p].rson <= r) {
    return T[p];
  }
  int mid = (T[p].lson + T[p].rson) >> 1;
  if (l <= mid && mid >= r) return Query((p << 1), l, r);
  if (mid < r && l > mid) return Query((p << 1 | 1), l, r);
  if (l <= mid && mid < r)
    return Query((p << 1), l, r) + Query((p << 1 | 1), l, r);
}
int n;
void Get() {
  int l, r;
  read(l);
  read(r);
  Segment_Node now = Query(1, l, r);
  int ans = 0;
  for (int i = 0; i <= Lim; ++i) {
    ans = max(ans, now.Mx[i] + now.Mx[Lim ^ i]);
  }
  cout << ans << '\n';
}
int main() {
  read(n);
  read(k);
  Lim = (1 << k) - 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < k; ++j) {
      read(a[i][j]);
    }
  }
  Build(1, 1, n);
  int Q;
  read(Q);
  while (Q--) {
    int opt;
    read(opt);
    if (opt == 2) {
      Get();
    } else {
      int pos;
      read(pos);
      for (int i = 0; i < k; ++i) {
        read(a[pos][i]);
      }
      Update(1, pos);
    }
  }
  return 0;
}
