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;
inline char gc(void) {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <class T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  static char c = gc();
  for (; !isdigit(c); c = gc())
    if (c == '-') f = -f;
  for (; isdigit(c); c = gc()) x = x * 10 + (c & 15);
  x *= f;
}
inline void readstr(char *s) {
  do *s = gc();
  while ((*s == ' ') || (*s == '\n') || (*s == '\r'));
  do *(++s) = gc();
  while ((~*s) && (*s != ' ') && (*s != '\n') && (*s != '\r'));
  *s = 0;
  return;
}
inline void readch(char &x) {
  while (isspace(x = gc()))
    ;
}
char pf[100000], *o1 = pf, *o2 = pf + 100000;
template <class T>
inline void println(T x, char c = '\n') {
  if (x < 0)
    (o1 == o2 ? fwrite(pf, 1, 100000, stdout), *(o1 = pf)++ = 45 : *o1++ = 45),
        x = -x;
  static char s[15], *b;
  b = s;
  if (!x) *b++ = 48;
  for (; x; *b++ = x % 10 + 48, x /= 10)
    ;
  for (; b-- != s; (o1 == o2          ? fwrite(pf, 1, 100000, stdout),
                    *(o1 = pf)++ = *b : *o1++ = *b))
    ;
  (o1 == o2 ? fwrite(pf, 1, 100000, stdout), *(o1 = pf)++ = c : *o1++ = c);
}
template <class T>
inline void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
template <class T>
inline void writeln(T x, char c = '\n') {
  write(x);
  putchar(c);
}
template <class T>
inline void chkmax(T &x, const T y) {
  x > y ? x = x : x = y;
}
template <class T>
inline void chkmin(T &x, const T y) {
  x < y ? x = x : x = y;
}
const int Maxn = 2e5 + 5;
int n, m, k, s, b[Maxn][5];
struct Node {
  int val[32];
  Node(void) { memset(val, 0, sizeof(val)); }
  inline Node operator+(const Node &rhs) const {
    Node ret;
    for (int i = 0; i < s; i++) ret.val[i] = max(val[i], rhs.val[i]);
    return ret;
  }
} t[Maxn << 2], qry;
struct SegmentTree {
  inline void pushup(int pos) { t[pos] = t[pos << 1] + t[pos << 1 | 1]; }
  inline void build(int pos, int l, int r) {
    if (l == r) {
      for (int i = 0; i < s; i++)
        for (int j = 0; j < k; j++)
          if (i & (1 << j))
            t[pos].val[i] += b[l][j];
          else
            t[pos].val[i] -= b[l][j];
      return;
    }
    int mid = l + r >> 1;
    build(pos << 1, l, mid);
    build(pos << 1 | 1, mid + 1, r);
    pushup(pos);
  }
  inline void update(int pos, int l, int r, int idx) {
    if (l == r) {
      memset(t[pos].val, 0, sizeof(t[pos].val));
      for (int i = 0; i < s; i++)
        for (int j = 0; j < k; j++)
          if (i & (1 << j))
            t[pos].val[i] += b[l][j];
          else
            t[pos].val[i] -= b[l][j];
      return;
    }
    int mid = l + r >> 1;
    if (idx <= mid)
      update(pos << 1, l, mid, idx);
    else
      update(pos << 1 | 1, mid + 1, r, idx);
    pushup(pos);
  }
  inline Node query(int pos, int l, int r, int L, int R) {
    if (L <= l && R >= r) return t[pos];
    int mid = l + r >> 1;
    if (L <= mid && R > mid)
      return query(pos << 1, l, mid, L, R) +
             query(pos << 1 | 1, mid + 1, r, L, R);
    if (L <= mid) return query(pos << 1, l, mid, L, R);
    if (R > mid) return query(pos << 1 | 1, mid + 1, r, L, R);
  }
} T;
signed main(void) {
  read(n), read(k);
  s = 1 << k;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < k; j++) read(b[i][j]);
  T.build(1, 1, n);
  read(m);
  for (int opt, l, r; m; m--) {
    read(opt);
    if (opt == 1) {
      read(l);
      for (int i = 0; i < k; i++) read(b[l][i]);
      T.update(1, 1, n, l);
    } else {
      read(l), read(r);
      int ret = 0;
      qry = T.query(1, 1, n, l, r);
      for (int i = 0; i < s; i++)
        chkmax(ret, qry.val[i] + qry.val[i ^ (s - 1)]);
      writeln(ret);
    }
  }
  return 0;
}
