#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	char s[8][9];
	
	for(int i = 0; i < 8; i++){
		scanf("%s", s[i]);
	}
	
	int num = 90;
	while(num <= 270){
		
		printf("%d\n", num);
		char tmp[9],t;
		strcpy(tmp, s[0]);
		t = s[7][0];
	
		for(int i = 7; i > 0; i--){
			s[0][i] = s[i][0];
			s[i][0] = s[7][i];
			s[7][i] = s[i][7];
			s[i][7] = tmp[i];
		}
		s[0][7] = s[0][0];
		s[0][0] = t;
	
		for(int i = 0; i < 8; i++){
				printf("%s\n", s[i]);
		}
		num  += 90;
	}
	return(0);
}