#include <iostream>

using namespace std;


int main()
{
    int n, m;
    int arr[10][10] = { {0} };
    int k;
    char op;
    int a, b;
    cin >> n >> m; //n行m列
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> arr[i][j];
        }
    }
    cin >> k;  //执行k次操作
    while(cin>>op>>a>>b)
    {
        if (op == 'r') //行变换
        {
            for (int i = 1; i <= m; i++)
            {
                int tmp = arr[a][i];
                arr[a][i] = arr[b][i];
                arr[b][i] = tmp;
            }
            k--;
        }
        else if(op == 'c') //列变换
        {
            for (int i = 1; i <= n; i++)
            {
                int tmp = arr[i][a];
                arr[i][a] = arr[i][b];
                arr[i][b] = tmp;
            }
            k--;
        }
        else
        {
            k--;
        }
        if (k == 0)
        {
            break;
        }
    }
    
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}