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

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

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.

Output

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 '?'.

Sample Input

110010
011100
011110
110110
010100
011110
000011
000101
010110
00001110
00000100
01010110
0

Sample Output

?
th5
Tion
THE

Kanpur-Kolkata 2004-2005


Added by:Jimmy
Date:2008-12-09
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ACM Kanpur 2004

hide comments
2024-12-09 11:41:26
nice problem

Last edit: 2024-12-09 11:41:43
2022-09-06 12:19:44 [Rampage] Blue.Mary
I've given my output to simes' test cases in the forum, hope it helps.
2013-08-11 21:20:35 Simes
Moved my question to the forum at http://discuss.spoj.com/t/wa-in-braille/24356

Last edit: 2020-04-10 12:31:00
2011-07-09 12:09:54 Hagen von Eitzen
The problem formulation contradicts itself:
"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." is not an *example* of what is written before.
Instead, it directly *contradicts* the previous statement "Each numeric digit 0-9 requires one cell, with character index the digit itself."
as the latter implies that "10" MUST be encoded as #a_ and not as #j.

So what is correct? Does (in number mode) #j translate to "10" or is it illegal? Should we infer that #z translates to "26"? And are #ja, #aj, #jj valid encodings of "101", "110", "1010", respectivly?
2011-07-08 21:14:31 Hagen von Eitzen
Is there no bound on line length?
2010-09-10 04:22:19 Ilya Seleznev
judge also uses capital sign to switch from "digit mode" to "letter mode". Beware!
2010-09-08 12:02:11 Ilya Seleznev
What I should output, if no printable character is decoded? For example if input have only (number_sign, number_sign) etc?
2010-03-10 13:14:39 Tony Beta Lambda
Use scanf() instead of gets().
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.