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

int main() {
	vector<string> v;
	for(int i = 0; i < 8; i++) {
		string s;
		cin >> s;
		v.push_back(s);
	}

	for(int i = 1; i <= 3; i++) {
		cout << i * 90 << endl;
		for(int j = 0; j < 8; j++) {
			for(int k = 0; k < 8; k++) {
				char c;
				switch(i) {
					case 1: c = v[7 - k][j]; break;
					case 2: c = v[7 - j][7 - k]; break;
					case 3: c = v[k][7 - j]; break;
				}
				cout << c;
			}
			cout << endl;
		}
	}
	return 0;
}