Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.

That element can store information about the matrix of integers size n × m. There are n + m inputs in that element, i.e. each row and each column can get the signal. When signal comes to the input corresponding to some row, this row cyclically shifts to the left, that is the first element of the row becomes last element, second element becomes first and so on. When signal comes to the input corresponding to some column, that column shifts cyclically to the top, that is first element of the column becomes last element, second element becomes first and so on. Rows are numbered with integers from 1 to n from top to bottom, while columns are numbered with integers from 1 to m from left to right.

Artem wants to carefully study this element before using it. For that purpose he is going to set up an experiment consisting of q turns. On each turn he either sends the signal to some input or checks what number is stored at some position of the matrix.

Artem has completed his experiment and has written down the results, but he has lost the chip! Help Artem find any initial matrix that will match the experiment results. It is guaranteed that experiment data is consistent, which means at least one valid matrix exists.

Input

The first line of the input contains three integers n, m and q (1 ≤ n, m ≤ 100, 1 ≤ q ≤ 10 000) — dimensions of the matrix and the number of turns in the experiment, respectively.

Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≤ ti ≤ 3) that defines the type of the operation. For the operation of first and second type integer ri (1 ≤ ri ≤ n) or ci (1 ≤ ci ≤ m) follows, while for the operations of the third type three integers ri, ci and xi (1 ≤ ri ≤ n, 1 ≤ ci ≤ m,  - 109 ≤ xi ≤ 109) are given.

Operation of the first type (ti = 1) means that signal comes to the input corresponding to row ri, that is it will shift cyclically. Operation of the second type (ti = 2) means that column ci will shift cyclically. Finally, operation of the third type means that at this moment of time cell located in the row ri and column ci stores value xi.

Output

Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value.

If there are multiple valid solutions, output any of them.

Examples

Input

2 2 6
2 1
2 2
3 1 1 1
3 2 2 2
3 1 2 8
3 2 1 8


Output

8 2 
1 8 


Input

3 3 2
1 2
3 2 2 5


Output

0 0 0 
0 0 5 
0 0 0 
import java.io.*;
import java.util.*;

import static java.lang.Math.*;


public class Main {
    FastScanner in;
    PrintWriter out;

    static final String FILE = "";

    public void solve() {
        int n = in.nextInt(), m = in.nextInt(), q = in.nextInt();
        int ms[][] = new int[1000][1000];
        int a[] = new int[q];
        int b[] = new int[q];
        int c[] = new int[q];
        int d[] = new int[q];

        for (int i = 0; i < q; i++) {
            a[i] = in.nextInt();
            if (a[i] == 1) {
                // STROKA
                b[i] = in.nextInt() - 1;
                int ff = ms[b[i]][0];
                for (int z = 0; z < m; z++)
                    ms[b[i]][z] = ms[b[i]][z + 1];
                ms[b[i]][m - 1] = ff;
            } else if (a[i] == 2) {
                // STOLBES
                b[i] = in.nextInt() - 1;
                int ff = ms[0][b[i]];
                for (int z = 0; z < n; z++)
                    ms[z][b[i]] = ms[z + 1][b[i]];
                ms[n - 1][b[i]] = ff;
            } else {
                b[i] = in.nextInt() - 1;
                c[i] = in.nextInt() - 1;
                d[i] = in.nextInt();
                ms[b[i]][c[i]] = d[i];
            }
        }

        int cpy[] = new int[1000];
        for (int i = q - 1; i >= 0; i--) {
            if (a[i] == 1) {
                for (int kek = 0; kek < m - 1; kek++) {
                    int ff = ms[b[i]][0];
                    for (int z = 0; z < m; z++)
                        ms[b[i]][z] = ms[b[i]][z + 1];
                    ms[b[i]][m - 1] = ff;
                }
            } else if (a[i] == 2) {
                for (int kek = 0; kek < n - 1; kek++) {
                    int ff = ms[0][b[i]];
                    for (int z = 0; z < n; z++)
                        ms[z][b[i]] = ms[z + 1][b[i]];
                    ms[n - 1][b[i]] = ff;
                }
            }
        }

        for (int i = 0; i < n; i++) {
            for (int z = 0; z < m; z++)
                out.print(ms[i][z] + " ");
            out.println();
        }
    }

    public void run() {
        if (FILE.equals("")) {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
        } else {
            try {
                in = new FastScanner(new FileInputStream(FILE +
                        ".in"));
                out = new PrintWriter(new FileOutputStream(FILE +
                        ".out"));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
        solve();
        out.close();
    }

    public static void main(String[] args) {
        (new Main()).run();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }
    }

    class Pair<A extends Comparable<A>, B extends Comparable<B>>
            implements Comparable<Pair<A, B>> {
        public A a;
        public B b;

        public Pair(A a, B b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(Pair<A, B> o) {
            if (o == null || o.getClass() != getClass())
                return 1;
            int cmp = a.compareTo(o.a);
            if (cmp == 0)
                return b.compareTo(o.b);
            return cmp;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            Pair<?, ?> pair = (Pair<?, ?>) o;

            if (a != null ? !a.equals(pair.a) : pair.a != null) return
                    false;
            return !(b != null ? !b.equals(pair.b) : pair.b != null);
        }
    }

    class PairInt extends Pair<Integer, Integer> {
        public PairInt(Integer u, Integer v) {
            super(u, v);
        }
    }

    class PairLong extends Pair<Long, Long> {
        public PairLong(Long u, Long v) {
            super(u, v);
        }
    }

}