#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;} template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;} int nextInt() { int x; scanf("%d", &x); return x;} int main2() { int N = nextInt(); int A = 0; int B = 0; int k = 1; while (N > 0) { int d = N % 10; int a = 1; int b = d - 1; while (a == 7 || b == 7) { a++; b--; } N /= 10; A += a * k; B += b * k; k *= 10; } cout << A << " " << B << endl; return 0; } int main() { for (;!cin.eof();cin>>ws) main2(); return 0; }