n = io.read("*n") ret, m, mul = 0, n, 1 while(0 < m) do a = m % 10 if(a == 7) then a = 6 end ret, m, mul = ret + mul * a, math.floor(m / 10), mul * 10 end io.write(string.format("%d %d\n", ret, n - ret))