#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>> operasi_hori(vector<vector<int>>& me){
int N=me.size();
int M=me[0].size();
for(int i=0;i<N/2;i++){
for(int j=0;j<M;j++){
swap(me[i][j], me[i+N-1][j]);
}
}
return me;
}
vector<vector<int>> operasi_ver(vector<vector<int>>& me){
int N=me.size();
int M=me[0].size();
for(int i=0;i<N;i++){
for(int j=0;j<M/2;j++){
swap(me[i][j], me[i][j+N-1]);
}
}
return me;
}
int main(){
int t[100][100],y[100][100],x,M,N;
cin>>N>>M>>x;
vector<vector<int>> me(N, vector<int>(M));
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
cin>>me[i][j];
}
}
while(x!=0){
string op;
cin>>op;
if(op=="_"){
operasi_hori(me);
}else if(op=="|"){
operasi_ver(me);
}
x--;
}
N=me.size();
M=me[0].size();
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
cout<<me[i][j]<<" ";
}cout<<endl;
}
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHZlY3Rvcj4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIAp2ZWN0b3I8dmVjdG9yPGludD4+IG9wZXJhc2lfaG9yaSh2ZWN0b3I8dmVjdG9yPGludD4+JiBtZSl7CglpbnQgTj1tZS5zaXplKCk7CglpbnQgTT1tZVswXS5zaXplKCk7Cglmb3IoaW50IGk9MDtpPE4vMjtpKyspewoJICAgIGZvcihpbnQgaj0wO2o8TTtqKyspewoJICAgICAgICBzd2FwKG1lW2ldW2pdLCBtZVtpK04tMV1bal0pOwogICAgICAgIH0KCX0KCXJldHVybiBtZTsKfQogCnZlY3Rvcjx2ZWN0b3I8aW50Pj4gb3BlcmFzaV92ZXIodmVjdG9yPHZlY3RvcjxpbnQ+PiYgbWUpewoJaW50IE49bWUuc2l6ZSgpOwoJaW50IE09bWVbMF0uc2l6ZSgpOwoJZm9yKGludCBpPTA7aTxOO2krKyl7CgkgICAgZm9yKGludCBqPTA7ajxNLzI7aisrKX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