N = gets.to_i a, b = [], [] N.to_s.each_char do |n| if n == '7' a << 6 b << 1 else a << n b << 0 end end a, b = a.join.to_i, b.join.to_i puts N == a + b ? "#{a} #{b}" : -1