#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	string s;
	char b[8][8],nb[8][8];
	rep(i,8) {
		cin >> s;
		rep(j,8) {
			b[i][j] = s[j];
		}
	}
	rep2(i,1,4) {
		cout << 90*i << endl;
		rep(i,8) {
			rep(j,8) {
				nb[i][j] = b[7-j][i];
			}
		}
		rep(i,8) {
			rep(j,8) {
				b[i][j] = nb[i][j];
				cout << b[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}