import java.util.Scanner;
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] array = new int[n][m];
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                array[i][j] = sc.nextInt();
            }
        }
        int time = sc.nextInt();
        for(int i = 0 ; i < time ; i++) {
            String str = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(str.contains("c")) {
                for(int h = 0 ; h < n ; h++) {
                    int temp = array[h][a-1];
                    array[h][a-1] = array[h][b-1];
                    array[h][b-1] = temp;
                }
            } else if(str.contains("r")) {
                for(int l = 0 ; l < m ; l++) {
                    int temp = array[a-1][l];
                    array[a-1][l] = array[b-1][l];
                    array[b-1][l] = temp;
                }
            }
        }
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
}