#include <iostream>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;
typedef long long ll;


void kai(string z[], int hk){
	string w[8];
	fill(w,w+8,"          ");
	if(hk==1)
		rep(i,8) rep(j,8) w[j][7-i]=z[i][j];
	else if(hk==2)
		rep(i,8) rep(j,8) w[7-i][7-j]=z[i][j];
	else
		rep(i,8) rep(j,8) w[7-j][i]=z[i][j];
	rep(i,8) cout << w[i] << endl;
}

int main() {
	string ba[8];
	
	rep(i,8) cin >> ba[i];
	cout << "90" << endl;
	kai(ba,1);
	cout << "180" << endl;
	kai(ba,2);
	cout << "270" << endl;
	kai(ba,3);
	
	return 0;
}