#include <iostream>
using namespace std;
int main() {
    int m, n, x, a[99][99], o1, o2,z[99];
    char t;
    cin >> m >> n;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    cin >> x;
    while(x)
    {
        cin >> t >> o1 >> o2;
        if (t == 'r') {
            for (int j = 0; j < m; j++) {
                z[j] = a[o1 - 1][j];
                a[o1 - 1][j] = a[o2 - 1][j];
                a[o2 - 1][j] = z[j];
            }
        } 
        else if (t == 'c') {
            for (int i = 0; i < n; i++) {
                z[i] = a[i][o1 - 1];
                a[i][o1 - 1] = a[i][o2 - 1];
                a[i][o2 - 1] = z[i];
            }
        } else ;
        x--;
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}