#include <iostream>
using namespace std;
int main()
{
	int i, j;
	char p[8][9], r;
	for (i = 0; i < 8; i++)
		cin >> p[i];
	cout << 90 << endl;
	for (i = 0; i < 8; i++)
	{
		for (j = 7; j >= 0; j--)
		{
			cout << p[j][i];
		}
		cout << endl;
	}
	cout << 180 << endl;
	for (i = 7; i >= 0; i--)
	{
		for (j = 7; j >= 0; j--)
		{
			cout << p[i][j];
		}
		cout << endl;
	}
	cout << 270 << endl;
	for (i = 0; i < 8; i++)
	{
		for (j = 7; j >= 0; j--)
		{
			cout << p[i][j];
		}
		cout << endl;
	}
}