#include <iostream>
#include <cstdio>

using namespace std;

void roll();

char pattern[10][10];
char tmp[10][10];

int main()
{
	for (int i = 0; i < 8; i++){
		scanf("%s", pattern[i]);
	}
	
	for (int j = 0; j < 3; j++){
		roll();
		printf("%d\n", (j + 1) * 90);
		//cout << (j + 1) * 90 << endl;
		for (int i = 0; i < 8; i++){
			printf("%s\n", pattern[i]);
		}
	}
	return (0); 
}

void roll()
{
	for (int i = 0; i < 8; i++){
		for (int j = 0; j < 8; j++){
			tmp[j][7 - i] = pattern[i][j];
		}
	}
	for (int i = 0; i < 8; i++){
		for (int j = 0; j < 8; j++){
			pattern[i][j] = tmp[i][j];
		}
	}
}