using System; using System.Collections.Generic; using System.Linq; class Solution { static char[][] Rotate(char[][] data) { int h = data.Length; int w = data[0].Length; var result = Enumerable.Range(0, w).Select(_ => new char[h]).ToArray(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { result[x][Math.Abs(h - y - 1)] = data[y][x]; } } return result; } static string Multiply(IList str, int k) { var result = ""; foreach (var c in str) { result += new string(c, k); } return result; } static void Main() { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int r = vals[0]; int k = vals[1]; vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int h = vals[0]; int w = vals[1]; var data = new char[h][]; for (int i = 0; i < h; i++) { data[i] = Console.ReadLine().ToArray(); } for (int rr = 0; rr < r; rr += 90) { data = Rotate(data); } for (int y = 0; y < data.Length; y++) { var str = Multiply(data[y], k); for (int i = 0; i < k; i++) { Console.WriteLine(str); } } } }