# Copyright (C) 2009 Igor V. Burago

def encode(num)
    result = []
    while num != 0
        group = num % 20
        result << (group == 0 ? '*' : '.' * (group % 5) + '|' * (group / 5))
        num /= 20
    end
    result.reverse.join(' ')
end

SYMBOLS = { '*' => 0, '.' => 1, '|' => 5 }

def decode(str)
    num = 0
    groups = str.split.map! { |d| d.split('').inject(0) { |s, x| s + SYMBOLS[x] } }
    groups.reverse!.each_with_index { |x, i| num += x * 20 ** i }
    num
end

unless ARGV.empty?
    ARGV.each { |x| puts encode(x.to_i) }
else
    File.open('output.txt', 'w') do |output|
        output.puts encode(IO.readlines('input.txt').inject(0) { |s, x| s + decode(x) })
    end
end
