#include int check_7(int n){ if(n < 0){ n *=-1; } while(n > 0){ if(n % 10 == 7){ return 1; } n /= 10; } return 0; } int main(){ int n; scanf("%d",&n); int a = n,b = 0; while(check_7(a) == 1 || check_7(b) == 1){ a--; b++; } printf("%d %d\n",a,b); return 0; }