
const 
	MAXN = 200;

var 
	a, answer : array [0 .. MAXN, 0 .. 2 * MAXN] of integer;
	n : integer;

procedure rotate;
var 
	z, cur, i, j : integer;
	begin
		for i := 1 to n do begin
			z := 2 * (n - i) + 1;
			cur := 1;
			answer[i][cur] := a[n - i + 1][z];
			inc(cur);
			for j := n - i + 2 to n do begin
				answer[i][cur] := a[j][z + 1];
				inc(cur);
				answer[i][cur] := a[j][z];
				inc(cur);
			end;
		end;
	end;

var 
	i, j : integer;
	s : string;

begin
	reset(input, 'triangle.in');
	rewrite(output, 'triangle.out');
	read(n);                             
	for i := 1 to n do begin
		for j := 1 to 2 * i - 1 do begin
			read(a[i][j]);
		end;
	end;
	readln;
	readln(s);
	assert((s = 'clockwise') or (s = 'counterclockwise'));
	rotate;
	if (s = 'clockwise') then begin
		a := answer;
		rotate;
	end;	
	for i := 1 to n do begin
		for j := 1 to 2 * i - 1 do begin
			if (j > 1) then
				write(' ');
			write(answer[i][j]);
		end;
		writeln;
	end;
	close(input);
	close(output);
end.
