#include <bits/stdc++.h>

using namespace std;

string MapBefore[8], MapAfter[8];

void solve() {
	char tmp[9];

	for (int j = 0; j < 8; j++) {
		for (int i = 0; i < 8; i++) {
			tmp[7-i] = MapBefore[i][j];
		}
		tmp[8] = '\0';
		MapAfter[j] = tmp;
	}
}

int main() {

	for (int i = 0; i < 8; i++) {
		cin >> MapBefore[i];
	}

	for (int i = 1; i < 4; i++) {
		solve();
		cout << 90 * i << endl;
		for (int i = 0; i < 8; i++) {
			cout << MapAfter[i] << endl;
		}
		for (int i = 0; i < 8; i++) {
			MapBefore[i] = MapAfter[i];
		}
	}
	
	return 0;
}
