#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;
}
vector<vector<int>> operasi_90(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[j][i]);
}
}
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);
}else if(op=="90"){
operasi_90(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+JiBtZSl7CglpbnQgTj1tZS5zaXplKCk7CglpbnQgTT1tZVswXS5zaXplKCk7Cglmb3IoaW50IGk9MDtpPE4vMjtpKyspewoJICAgIGZvcihpbnQgaj0wO2o8TTtqKyspewoJICAgICAgICBzd2FwKG1lW2ldW2pdLCBtZVtpK04tMV1bal0pOwogICAgICAgIH0KCX0KCXJldHVybiBtZTsKfQogCnZlY3Rvcjx2ZWN0b3I8aW50Pj4gb3BlcmFzaV92ZXIodmVjdG9yPHZlY3Rvcjxp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