program main
  implicit none
  integer*8::N,A,B
  integer::i,j,tmp
  data B/0/
  read *,N
  A = N
  tmp = 1
  do
     if(N.eq.0) exit
     if(MOD(N,10).eq.7) then
        A=A-tmp
        B=B+tmp
     endif
     tmp = tmp*10
     N = N/10
  end do
  print '(i0," ",i0)',A,B
end program main