Switchboard

Can you sort out the mess?

Run 1

Input

A B C D
| | | |
 X  | |
| |  X
| | | |
|  X  |
| | | |

Expected Output

B D A C