#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main () {
	vector<string> t(8);
	for (int i = 0; i < 8; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < 3; i++) {
		vector<string> res = t;
		for (int y = 0; y < 8; y++) {
			for (int x = 0; x < 8; x++) {
				t[x][8 - y - 1] = res[y][x];
			}
		}
		cout << 90 * (i + 1) << endl;
		for (int j = 0; j < 8; j++) {
			cout << t[j] << endl;
		}
	}
	return 0;
}