#include <cstdio>

#define MAX (8)

int main(void)
{
    char map[4][MAX][MAX + 1];
    
    for (int i = 0; i < MAX; i++){
        scanf("%s", map[0][i]);
    }
    
    for (int x = 1; x < 4; x++){
        for (int i = 0; i < MAX; i++){
            for (int j = 0; j < MAX; j++){
                map[x][i][j] = map[x - 1][j][MAX - i - 1];
            }
        }
    }
    
    for (int x = 3; x != 0; x--){
        printf("%d\n", 270 / x);
        for (int i = 0; i < MAX; i++){
            map[x][i][MAX] = '\0';
            printf("%s\n", map[x][i]);
        }
    }
    
    return (0);
}