#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	char ch[8][8],hoge[8][8];
	rep(i,8)rep(j,8)cin>>ch[i][j];
	rep(p,3){
		if(p==0)cout<<"90"<<endl;
		if(p==1)cout<<"180"<<endl;
		if(p==2)cout<<"270"<<endl;
		rep(i,8)rep(j,8)hoge[i][j]=ch[8-j-1][i];
		rep(i,8){
			rep(j,8){cout<<hoge[i][j];ch[i][j]=hoge[i][j];}
			cout<<endl;
		}
	}
	return 0;
}