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
import java.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        int n = ni(), k = ni(), m = 1;
        int all = 1<<k;
        while(m<n)m<<=1;
        long[][] a = new long[n][k];
        for(int i = 0; i< n; i++)
            for(int j = 0; j< k; j++)
                a[i][j] = nl();
        long[][] min = new long[32][m<<1], max = new long[32][m<<1];
        for(int b = 0; b< all; b++){
            for(int i = 0; i< n; i++){
                long val = 0;
                for(int j = 0; j< k; j++){
                    if(((b>>j)&1)==1)val+=a[i][j];
                    else val-=a[i][j];
                }
                min[b][i+m] = val;
                max[b][i+m] = val;
            }
            for(int i = n; i< m; i++){
                min[b][i] = IINF;
                max[b][i] = -IINF;
            }
            for(int i = m-1; i>= 0; i--){
                min[b][i] = Math.min(min[b][i<<1], min[b][i<<1|1]);
                max[b][i] = Math.max(max[b][i<<1], max[b][i<<1|1]);
            }
        }
        for(int qq = ni(); qq>0; qq--){
            int ty = ni();
            if(ty==1){
                int p = ni()-1;
                for(int i = 0; i< k; i++)a[p][i] = nl();
                for(int b = 0; b< all; b++){
                    long val = 0;
                    for(int j = 0; j< k; j++){
                        if(((b>>j)&1)==1)val+=a[p][j];
                        else val -= a[p][j];
                    }
                    min[b][p+m] = val;
                    max[b][p+m] = val;
                    for(int pp = (p+m)>>1; pp>0; pp>>=1){
                        min[b][pp] = Math.min(min[b][pp<<1], min[b][pp<<1|1]);
                        max[b][pp] = Math.max(max[b][pp<<1], max[b][pp<<1|1]);
                    }
                }
            }else{
                int l = ni()-1, r = ni()-1;
                long ans = 0;
                for(int b = 0; b< all; b++){
                    long mx = -IINF, mn = IINF;
                    for(int ll = l+m, rr = r+m+1; ll< rr; ll>>=1, rr>>=1){
                        if((ll&1)==1){
                            mx = Math.max(mx, max[b][ll]);
                            mn = Math.min(mn, min[b][ll]);
                            ll++;
                        }
                        if((rr&1)==1){
                            rr--;
                            mx = Math.max(mx, max[b][rr]);
                            mn = Math.min(mn, min[b][rr]);
                        }
                    }
                    ans = Math.max(ans, mx-mn);
                }
                pn(ans);
            }
        }
    }
    
    //SOLUTION END
    long mod = (long)998244353, IINF = (long)1e9+5;
    final int INF = (int)2e9, MAX = (int)2e5+1;
    DecimalFormat df = new DecimalFormat("0.0000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}    