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 ScanInt() {
  int x = 0;
  char ch = getchar();
  bool nega = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-')
    nega = 1;
  else
    x = x * 10 + ch - '0';
  ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  if (nega) x = -x;
  return x;
}
void Write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) Write(x / 10);
  putchar(x % 10 + '0');
}
const int N = 200005, K = 5;
int n, a[N][K + 2], kd;
int t[4 * N][(1 << K) + 2], tt;
void Enter() {
  n = ScanInt();
  kd = ScanInt();
  tt = (1 << kd) - 1;
  for (int i = 1, b_ = n; i <= b_; ++i)
    for (int j = 1, b_ = kd; j <= b_; ++j) a[i][j] = ScanInt();
}
void Build(int k, int l, int r) {
  if (l > r) return;
  if (l == r) {
    int w;
    for (int i = 0, b_ = tt; i <= b_; ++i) {
      w = 0;
      for (int j = 1, b_ = kd; j <= b_; ++j)
        if (((i >> (j - 1)) & 1ll) == 0)
          w -= a[l][j];
        else
          w += a[l][j];
      t[k][i] = w;
    }
    return;
  }
  int mid = (l + r) / 2;
  Build(2 * k, l, mid);
  Build(2 * k + 1, mid + 1, r);
  for (int i = 0, b_ = tt; i <= b_; ++i)
    t[k][i] = max(t[2 * k][i], t[2 * k + 1][i]);
}
void Update(int k, int l, int r, int i) {
  if (i < l || r < i) return;
  if (l == r) {
    int w;
    for (int i = 0, b_ = tt; i <= b_; ++i) {
      w = 0;
      for (int j = 1, b_ = kd; j <= b_; ++j)
        if (((i >> (j - 1)) & 1ll) == 0)
          w -= a[l][j];
        else
          w += a[l][j];
      t[k][i] = w;
    }
    return;
  }
  int mid = (l + r) / 2;
  Update(2 * k, l, mid, i);
  Update(2 * k + 1, mid + 1, r, i);
  for (int i = 0, b_ = tt; i <= b_; ++i)
    t[k][i] = max(t[2 * k][i], t[2 * k + 1][i]);
}
int Get(int k, int l, int r, int u, int v, int id) {
  if (v < l || r < u) return -1e9;
  if (u <= l && r <= v) return t[k][id];
  int mid = (l + r) / 2;
  return max(Get(2 * k, l, mid, u, v, id),
             Get(2 * k + 1, mid + 1, r, u, v, id));
}
void Apps() {
  int m = ScanInt();
  int id;
  while (m--) {
    id = ScanInt();
    if (id == 1) {
      int x = ScanInt();
      for (int i = 1, b_ = kd; i <= b_; ++i) a[x][i] = ScanInt();
      Update(1, 1, n, x);
    } else {
      int u = ScanInt();
      int v = ScanInt();
      int res = -1e9;
      for (int i = 0, b_ = tt; i <= b_; ++i)
        res =
            max(res, abs(Get(1, 1, n, u, v, i) + Get(1, 1, n, u, v, (i ^ tt))));
      Write(res);
      putchar('\n');
    }
  }
}
int main() {
  Enter();
  Build(1, 1, n);
  Apps();
}
