//http://ja.doukaku.org/103/ 投稿用
using System;
using System.Collections.Generic;
class Program {
	static void Main(string[] args) {
		Amida(@"A B C D E
| | |-| |
|-| | |-|
| |-| |-|
|-| |-| |
|-| | | |");
		Console.ReadLine();
	}

	static void Amida(string amidaText) {
		List<string> temp = new List<string>(amidaText.Split(new char[] { '\n' }));
		List<char> lastLine = new List<char>(temp[0].ToCharArray());
		foreach(string line in temp) {
			Console.WriteLine(line);
			for(int i = 1; i < line.Length; i = i + 2) {
				if(line[i] == '-'){
					lastLine.Reverse(i - 1, 3);
				}
			}
		}
		Console.WriteLine(lastLine.ToArray());
	}
}