BRAILLE - Braille Transcription
Visually handicapped people use Braille system of codes for reading and writing. The basic Braille symbol (or cell) is composed of six dots arranged in two vertical columns, each column being three dots high. This pattern produces 64 one-cell symbols with character index #(20a1 + 21a2 + 22a3 + 23a4 + 24a5 + 25a6), where ai = 1, if dot i is embossed up and zero otherwise. The positions of these dots are numbered as follows:
Many Braille codes are in use; one such is the Simple Braille System (SBS). In SBS alphabets in lower case are default characters; letters `a, b,..., z' have character indices `1, 2, ..., 26' respectively. The ``letter sign'' (dots 5-6) may be used optionally before a string of alphabets in lower case. Each numeric digit 0-9 requires one cell, with character index the digit itself. However the ``number sign'' (dots 3-4-5-6) is added before a string of numerals. In order to revert back to normal alphabets after a string of numerals, the ``letter sign'' is used. The blank cell is used as a space in alphabetic context and zero in numeric context. For example the numerals 1 - 10 are the same as the first ten letters of the alphabet, index of #a being 1 and #j being 10. SBS allows the contraction of `th', by a single cell with dots 1-4-5-6. A two-cell contraction for `tion' is allowed with dots 5-6 and dots 1-3-4-5.
There are no single-cell codes for capital letters in SBS. So a ``capital sign'' (dot 6) is inserted before a capital letter. Two ``capital signs'' are inserted to indicate that the string of alphabets that follows is capitalized. To revert back to normal alphabets (or numerals), the ``letter sign'' (or the ``number sign'') is used. SBS ignores punctuation marks altogether.
You are required to write a program for SBS transcription that converts an SBS code to English.
Input consists of multiple test cases.
In each test case there is an SBS code. It is given in three input lines containing a certain number of Braille cells. Each Braille cell is represented by a 3×2 array of 0's and 1's, appearing in an odd and the next even numbered column of the three input lines, where `1' is used for an embossed dot and `0' otherwise.
A line that is not a part of an SBS code, containing a single zero in column 1 terminates input.
For each test case, output the SBS code in English, in one line. In case the input does not conform to SBS rules stated above output simply the sign `?'.
110010 011100 011110 110110 010100 011110 000011 000101 010110 00001110 00000100 01010110 0
? th5 Tion THE