x = [list(input()) for _ in [0]*8]

for i in [1,2,3]:

  x = list(zip(*x[::-1]))

  print(i*90)

  for e in x: print("".join(e))
x = [input() for _ in [0] * 8]

for i in [1, 2, 3]:

  x = list(zip(*x[::-1]))

  print(i*90)

  for e in x:

    print("".join(e))
x = [list(input()) for _ in [0] * 8]
for i in [1, 2, 3]:
    x = list(zip(*x[::-1]))
    print(i * 90)
    for e in x:
        print("".join(e))

x = [input() for _ in [0] * 8]
for i in [1, 2, 3]:
    x = list(zip(*x[::-1]))
    print(i * 90)
    for e in x:
        print("".join(e))

-x = [list(input()) for _ in [0] * 8] +x = [input() for _ in [0] * 8]