#include <iostream>
#include <cstring>
using namespace std;
char p[8][9];
void rotate()
{
	int i;
	char tmp[8][9];
	for (i = 0; i < 8; i++)
		strcpy(tmp[i], p[i]);
	for (int x = 7; x >= 0; x--)
		for (int y = 0; y < 8; y++)
			tmp[y][x] = p[7-x][y];
	for (i = 0; i < 8; i++)
	{
		strcpy(p[i], tmp[i]);
		cout << p[i] << endl;
	}
}
int main()
{
	int i;
	for (i = 0; i < 8; i++)
		cin >> p[i];
	for (i = 1; i <= 3; i++)
	{
		cout << 90*i << endl;
		rotate();
	}
}