#include <stdio.h>
int main()

{
    int m = 0;//列
    int n = 0;//行
    int arr[10][10] = { 0 };
    int k = 0;//操作的次数
    char ch = 0;//代表操作的字符
    int a = 0;
    int b = 0;
//读取数据
    scanf("%d%d", &n, &m);
    int i = 0;
    int j = 0;
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &arr[i][j]);
        }
    }
    scanf("%d", &k);
    for (i = 0; i < k; i++) {
        scanf(" %c %d %d", &ch, &a, &b);
        if (ch== 'r') {
//交换a和b行
            for (j = 0; j < m; j++) {
                int tmp = arr[a - 1][j];
                arr[a - 1][j] = arr[b - 1][j];
                arr[b - 1][j] = tmp;
            }
        } else if (ch == 'c') {
//交换a和b列
            for (j = 0; j < n; j++) {
                int tmp = arr[j][a - 1];
                arr[j][a - 1] = arr[j][b - 1];
                arr[j][b - 1] = tmp;
            }
        }
    }
//输出
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }

    return 0;
}