#include <stdio.h>
#include <string.h>

#define MAX 8
char table[MAX][MAX];

void rotate_90()
{
	char tmp[MAX][MAX];
	for ( int i = 0 ; i < MAX ; i++ ) {
		for ( int j = 0 ; j < MAX ; j++ ) {
			tmp[j][(MAX-1)-i] = table[i][j];	
		}
	}

	memcpy( table, tmp, sizeof( table ) );
}

void print_table() 
{
	for ( int i = 0 ; i < MAX ; i++ ) {
		for ( int j = 0 ; j < MAX ; j++ ) {
			printf( "%c", table[i][j] );
		}
		printf( "\n" );
	}
}

int main()
{
	int i = 0;

	for ( i = 0 ; i < MAX ; i++ ) {
		scanf( "%s", table[i] );
	}

	for ( i = 1 ; i < 4 ; i++ ) {
		rotate_90();
		printf( "%d\n", 90 * i );
		print_table();
	}

	return 0;
}

