s = gets.chomp.chars.map(&:to_i) a = Array.new(s.size, 0) b = Array.new(s.size, 0) s.each_with_index do |c, i| if c == 7 a[i] = 1 b[i] = 6 else a[i] = c b[i] = 0 end end puts "#{a.join.to_i(10)} #{b.join.to_i(10)}"