import java.util.Scanner; class no544{ public static void main(String[] args) { Scanner stdIn=new Scanner(System.in); int n=stdIn.nextInt(),i,a,b,t=1; for(i=1;t!=0;i+=17) { a=i; b=n-i; t=0; do { if(a%10==7) t++; a/=10; }while(a!=0); do { if(b%10==7) t++; b/=10; }while(b!=0); } System.out.print(i-17+" "+(n-i+17)); } }