#include<iostream>
#include<string>
using namespace std;int main(){int i,j;string s[i=8],t;for(;i-->0;)getline(cin,s[i]);t="90\n";for(;++i<8;){for(j=0;j<8;)t+=s[j++][i];t+="\n";}t+="180\n";for(;i-->0;){for(j=8;j-->0;)t+=s[7-i][j];t+="\n";}t+="270\n";for(;++i<8;){for(j=8;j-->0;)t+=s[j][7-i];t+="\n";}cout<<t;return 0;}