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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author master_j
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MjInput in = new MjInput(inputStream);
        MjOutput out = new MjOutput(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        MjInput in;
        MjOutput out;
        int n;
        int m;
        int[][] a;

        void solve() {
            n = in.nextInt();
            m = in.nextInt();
            a = new int[n][m];

            String[] strs = in.nextLineArray(in.nextInt());
            for (int i = strs.length - 1; i >= 0; i--) {
                StringTokenizer tokenizer = new StringTokenizer(strs[i]);
                int t = Integer.parseInt(tokenizer.nextToken());
                if (t == 1)
                    do1(Integer.parseInt(tokenizer.nextToken()));
                if (t == 2)
                    do2(Integer.parseInt(tokenizer.nextToken()));
                if (t == 3)
                    do3(Integer.parseInt(tokenizer.nextToken()), Integer.parseInt(tokenizer.nextToken()), Integer.parseInt(tokenizer.nextToken()));
            }

            for (int[] ints : a) {
                for (int i : ints) {
                    out.print(i);
                    out.print(' ');
                }
                out.println();
            }

        }

        void do1(int r) {
            r--;
            int t = a[r][m - 1];
            for (int i = m - 1; i > 0; i--) a[r][i] = a[r][i - 1];
            a[r][0] = t;
        }

        void do2(int c) {
            c--;
            int t = a[n - 1][c];
            for (int i = n - 1; i > 0; i--) a[i][c] = a[i - 1][c];
            a[0][c] = t;
        }

        void do3(int r, int c, int x) {
            r--;
            c--;
            a[r][c] = x;
        }

        public void solve(int testNumber, MjInput in, MjOutput out) {
            this.in = in;
            this.out = out;
            solve();
        }

    }

    static class MjInput {
        private StringTokenizer stringTokenizer;
        private BufferedReader bufferedReader;

        public MjInput(InputStream is) {
            bufferedReader = new BufferedReader(new InputStreamReader(is));
        }

        public boolean hasMoreTokens() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                String nextLine = nextLine();
                if (nextLine == null)
                    return false;
                stringTokenizer = new StringTokenizer(nextLine);
            }
            return true;
        }

        public String nextLine() {
            try {
                stringTokenizer = null;
                return bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

        public String next() {
            return hasMoreTokens() ? stringTokenizer.nextToken() : null;
        }

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

        public String[] nextLineArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) res[i] = nextLine();
            return res;
        }

    }

    static class MjOutput extends PrintWriter {
        public MjOutput(Writer writer) {
            super(writer);
        }

        public MjOutput(OutputStream outputStream) {
            super(outputStream);
        }


        public void close() {
            super.close();
        }

    }
}
