using System.Collections.Generic;
public class Program {
public static void Main() {
string[] s=System.Console.ReadLine().Split();
int n = int.Parse(s[0]);
int m = int.Parse(s[1]);
Stack<string> st=new Stack<string>();
for(int i=0;i<n;i++)
{
string line = System.Console.ReadLine();
char[] cs = line.ToCharArray();
int p1 = 0;
int p2 = m - 1;
while (p1 < p2)
{
char temp = cs[p1];
cs[p1] = cs[p2];
cs[p2] = temp;
p1++;
p2--;
}
st.Push(new string(cs));
}
for(int j=0;j<n;j++)
{
System.Console.WriteLine(st.Pop());
}
}
}