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 MX = 200005;
const int MD = 998244353;
struct Info {
  int p[64];
};
Info Merge(Info a, Info b) {
  for (int i = 0; i < 32; i++) {
    a.p[i] = min(a.p[i], b.p[i]);
  }
  for (int i = 32; i < 64; i++) {
    a.p[i] = max(a.p[i], b.p[i]);
  }
  return a;
}
struct {
  int L, R;
  int pl, pr;
  Info info;
} T[2 * MX];
Info a[MX];
int buildTree(int L, int R) {
  static int tsz = 0;
  int cur = tsz++;
  T[cur].L = L;
  T[cur].R = R;
  if (L < R) {
    T[cur].pl = buildTree(L, (L + R) / 2);
    T[cur].pr = buildTree((L + R) / 2 + 1, R);
    T[cur].info = Merge(T[T[cur].pl].info, T[T[cur].pr].info);
  } else {
    T[cur].info = a[L];
  }
  return cur;
}
void upd(int i, int cur) {
  if (T[cur].L == T[cur].R) {
    T[cur].info = a[i];
    return;
  }
  if (i <= T[T[cur].pl].R) {
    upd(i, T[cur].pl);
  } else {
    upd(i, T[cur].pr);
  }
  T[cur].info = Merge(T[T[cur].pl].info, T[T[cur].pr].info);
}
Info get(int L, int R, int cur) {
  if (L <= T[cur].L && R >= T[cur].R) {
    return T[cur].info;
  }
  Info ret;
  bool has = false;
  if (L <= T[T[cur].pl].R && T[T[cur].pl].L <= R) {
    ret = get(L, R, T[cur].pl);
    has = true;
  }
  if (L <= T[T[cur].pr].R && T[T[cur].pr].L <= R) {
    Info tmp = get(L, R, T[cur].pr);
    if (has) {
      ret = Merge(ret, tmp);
    } else {
      ret = tmp;
    }
  }
  return ret;
}
void read(int i, int k) {
  Info tmp;
  int x[5];
  memset(x, 0, sizeof x);
  for (int j = 0; j < k; j++) {
    ignore = scanf("%d", x + j);
  }
  int t = 0;
  int s = 0;
  for (int i0 = 0; i0 < 2; i0++) {
    if (i0)
      s += x[0];
    else
      s -= x[0];
    for (int i1 = 0; i1 < 2; i1++) {
      if (i1)
        s += x[1];
      else
        s -= x[1];
      for (int i2 = 0; i2 < 2; i2++) {
        if (i2)
          s += x[2];
        else
          s -= x[2];
        for (int i3 = 0; i3 < 2; i3++) {
          if (i3)
            s += x[3];
          else
            s -= x[3];
          for (int i4 = 0; i4 < 2; i4++) {
            if (i4)
              s += x[4];
            else
              s -= x[4];
            tmp.p[t++] = s;
            if (i4)
              s -= x[4];
            else
              s += x[4];
          }
          if (i3)
            s -= x[3];
          else
            s += x[3];
        }
        if (i2)
          s -= x[2];
        else
          s += x[2];
      }
      if (i1)
        s -= x[1];
      else
        s += x[1];
    }
    if (i0)
      s -= x[0];
    else
      s += x[0];
  }
  for (int j = 0; j < 32; j++) {
    tmp.p[j + 32] = tmp.p[j];
  }
  a[i] = tmp;
}
int main() {
  int n, k;
  ignore = scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    read(i, k);
  }
  int root = buildTree(1, n);
  int q;
  ignore = scanf("%d", &q);
  while (q--) {
    int t;
    ignore = scanf("%d", &t);
    if (t == 1) {
      int i;
      ignore = scanf("%d", &i);
      read(i, k);
      upd(i, root);
    } else {
      int l, r;
      ignore = scanf("%d %d", &l, &r);
      Info ret = get(l, r, root);
      int ans = 0;
      for (int i = 0; i < 32; i++) {
        ans = max(ans, ret.p[i + 32] - ret.p[i]);
      }
      printf("%d\n", ans);
    }
  }
}
