import java.io.*;
import java.util.StringTokenizer;

public class triangle_vd {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

	String next() throws IOException {
		while ((str == null) || (!str.hasMoreTokens())) {
			SK = in.readLine();
			if (SK == null)
				return null;
			str = new StringTokenizer(SK);
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	int[][] rev(int[][] a) {
		int n = a.length;
		int[][] res = new int[n][2 * n - 1];
		for (int i = n - 1; i >= 0; --i) {
			res[n - 1 - i][0] = a[i][2 * i];
			int pos = 0;
			for (int j = i + 1; j < n; j++) {
				int tek = j - i;
				res[n - 1 - i][++pos] = a[j][2 * (j - tek + 1) - 1];
				res[n - 1 - i][++pos] = a[j][2 * (j - tek + 1) - 2];
			}
		}
		return res;
	}

	void print(int[][] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2 * i + 1; j++) {
				out.print(a[i][j] + " ");
			}
			out.println();
		}
	}

	void solve() throws IOException {
		int n = nextInt();
		assert n >= 1;
		assert n <= 200;
		int[][] a = new int[n][2 * n - 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2 * i + 1; j++) {
				a[i][j] = nextInt();
				assert a[i][j] >= 0;
				assert a[i][j] <= 9;
			}
		}
		String s = next();
		assert s.equals("clockwise") || s.equals("counterclockwise");
		if (s.equals("counterclockwise")) {
			print(rev(a));
		} else {
			print(rev(rev(a)));
		}

	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("triangle.in"));
		out = new PrintWriter("triangle.out");
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new triangle_vd().run();
	}

}