#include <iostream>
using namespace std;
#include <stack>
int main() {
    int n,m;
    cin>>n>>m;
    char ch;
    stack<char>s;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>ch;
            s.push(ch);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<s.top();
            s.pop();
        }
        cout<<endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")