import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.container; // SList, DList, BinaryHeap import std.typecons; // Tuple, Nullable, BigFlags import std.math; // math functions import std.numeric; // gcd, fft import std.bigint; // BigInt import std.random; // random import std.bitmanip; // BitArray import core.bitop; // bit operation import std.regex; // RegEx import std.uni; // unicode void main() { auto n = readln.chomp.to!int; auto a = n.toArray; auto b = a.dup, c = a.dup; foreach (i; 0..a.length) if (a[i] == 7) { b[i] = 3; c[i] = 4; } else if (a[i] == 8) { b[i] -= 2; c[i] = 2; } else if (a[i] > 0) { b[i] -= 1; c[i] = 1; } writeln(b.toInt, " ", c.toInt); } auto toArray(int n) { int[] r; if (n == 0) return [0]; for (; n > 0; n /= 10) r = (n % 10) ~ r; return r; } auto toInt(int[] a) { auto r = 0; foreach (ai; a) r = r * 10 + ai; return r; }