#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  string s[8];
  REP(i,8)
    cin >> s[i];
  REP(k,3) {
    cout << 90*(k+1) << endl;
    REP(y,8) {
      REP(x,8) {
        if (k==0)
          cout << s[7-x][y];
        else if (k==1)
          cout << s[7-y][7-x];
        else
          cout << s[x][7-y];
      }
    cout << endl;
    }
  }
}