#include <stdio.h>
int main() {
    int n = 0, m = 0;
    int i = 0, j = 0;
    int arr[20][20] = { 0 };
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &arr[i][j]);
        }
    }
    int k = 0;
    scanf("%d", &k);
    char t = 0;
    int a = 0;
    int b = 0;
    for (i = 0; i < k; i++) {
        scanf(" %c %d %d", &t, &a, &b);
        if (t == 'r') {
            for (j = 0; j < m; j++) {
                int temp = arr[a - 1][j];
                arr[a - 1][j] = arr[b - 1][j];
                arr[b - 1][j] = temp;
            }
        } else if (t == 'c') {
            for (j = 0; j < n; j++) {
                int temp = arr[j][a - 1];
                arr[j][a - 1] = arr[j][b - 1];
                arr[j][b - 1] = temp;
            }
        }
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}