using System;
using System.Collections.Generic;
using System.Text;
namespace digital_led_number
{
class Program
{
static void Main(string[] args)
{
var numbers = new Dictionary<string, int>();
List<string> replacedNumbersList = new List<string>();
List<int> finalNumbers = new List<int>();
List<string> result = new List<string>();
int iterator = 1;
int startingPoint = 0;
bool readLines = true;
numbers.Add("010101111", 0);
numbers.Add("000001001", 1);
numbers.Add("010011110", 2);
numbers.Add("010011011", 3);
numbers.Add("000111001", 4);
numbers.Add("010110011", 5);
numbers.Add("010110111", 6);
numbers.Add("010001001", 7);
numbers.Add("010111111", 8);
numbers.Add("010111001", 9);
while (readLines)
{
string line = Console.ReadLine();
if (String.IsNullOrEmpty(line))
{
readLines = false;
}
string replacedLine = GetReplacedString(line);
int numbersInLine = replacedLine.Length / 3;
for (int j = 0; j < replacedLine.Length; j+=3)
{
string x = replacedLine.Substring(j, 3);
replacedNumbersList.Add(x);
}
if (iterator % 3 == 0)
{
for (int i = 0; i < numbersInLine; i++)
{
string currentNumber = "";
for (int j = startingPoint + i; j < replacedNumbersList.Count; j+= numbersInLine)
{
currentNumber += replacedNumbersList[j];
}
finalNumbers.Add(numbers[currentNumber]);
}
startingPoint = replacedNumbersList.Count;
string final = "";
finalNumbers.ForEach(p => final += p.ToString());
result.Add(final);
}
if (readLines)
{
iterator++;
}
}
string someString = result[result.Count - 1];
string parsedSomeString = someString;
int iteratorMultiple = (iterator / 3) > 0 ? (iterator / 3) : 1;
int counterValue = parsedSomeString.Length / iteratorMultiple;
for (int j = 0; j < parsedSomeString.Length; j+= counterValue)
{
string x = parsedSomeString.Substring(j, counterValue);
Console.WriteLine(x);
}
}
static string GetReplacedString(string s)
{
return new StringBuilder(s)
.Replace(" ", "0")
.Replace("_", "1")
.Replace("|", "1")
.ToString();
}
}
}