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>
const long long maxn = 2e5 + 10;
long long N, K, seg[maxn << 2][32], tmp[10], Q, upd[10];
inline long long Max(long long a, long long b) { return a > b ? a : b; }
inline long long Min(long long a, long long b) { return a > b ? b : a; }
struct Node {
  long long f[32];
  Node() { memset(f, ~0x3f, sizeof(f)); }
  inline friend Node operator+(const Node& a, const Node& b) {
    Node ans;
    for (long long i = 0; i < 1 << K; ++i) {
      ans.f[i] = Max(a.f[i], b.f[i]);
    }
    return ans;
  }
};
inline long long read() {
  long long f = 1, r = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (isdigit(c)) {
    r = 10 * r + c - '0';
    c = getchar();
  }
  return f * r;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writesp(long long x) { write(x), putchar(' '); }
inline void writeln(long long x) { write(x), puts(""); }
inline void pushup(long long cur) {
  for (long long i = 0; i < (1 << K); ++i) {
    seg[cur][i] = Max(seg[cur << 1][i], seg[cur << 1 | 1][i]);
  }
}
void build(long long l, long long r, long long cur) {
  if (l == r) {
    for (long long i = 0; i < K; ++i) {
      tmp[i] = read();
    }
    for (long long i = 0; i < (1 << K); ++i) {
      for (long long j = 0; j < K; ++j) {
        if (i & (1 << j)) {
          seg[cur][i] += tmp[j];
        } else {
          seg[cur][i] -= tmp[j];
        }
      }
    }
    return;
  }
  build(l, ((l + r) >> 1), cur << 1),
      build(((l + r) >> 1) + 1, r, cur << 1 | 1);
  pushup(cur);
}
void update(long long l, long long r, long long pos, long long cur) {
  if (l == r) {
    for (long long i = 0; i < (1 << K); ++i) {
      seg[cur][i] = 0;
      for (long long j = 0; j < K; ++j) {
        if (i & (1 << j)) {
          seg[cur][i] += upd[j];
        } else {
          seg[cur][i] -= upd[j];
        }
      }
    }
    return;
  }
  if (((l + r) >> 1) >= pos)
    update(l, ((l + r) >> 1), pos, cur << 1);
  else
    update(((l + r) >> 1) + 1, r, pos, cur << 1 | 1);
  pushup(cur);
}
Node query(long long l, long long r, long long L, long long R, long long cur) {
  if (l >= L && r <= R) {
    Node node;
    for (long long j = 0; j < (1 << K); ++j) {
      node.f[j] = seg[cur][j];
    }
    return node;
  }
  Node ans;
  if (((l + r) >> 1) >= L) ans = ans + query(l, ((l + r) >> 1), L, R, cur << 1);
  if (((l + r) >> 1) < R)
    ans = ans + query(((l + r) >> 1) + 1, r, L, R, cur << 1 | 1);
  return ans;
}
signed main() {
  N = read(), K = read();
  build(1, N, 1);
  Q = read();
  for (long long i = 1; i <= Q; ++i) {
    long long w = read();
    if (w == 1) {
      long long pos = read();
      for (long long j = 0; j < K; ++j) {
        upd[j] = read();
      }
      update(1, N, pos, 1);
    } else {
      long long l = read(), r = read(), mx = -0x3f3f3f3f;
      Node ans = query(1, N, l, r, 1);
      for (long long i = 0; i < (1 << K); ++i) {
        long long s1 = i, s2 = i ^ ((1 << K) - 1);
        mx = Max(mx, ans.f[s1] + ans.f[s2]);
      }
      writeln(mx);
    }
  }
  return 0;
}
