We are given an integer n (1 ≤ n ≤ 10^7). Need to output two composite integers a,b such that a - b = n, with 2 ≤ a,b ≤ 10^9. Composite numbers are integers that have at least one divisor other than 1 and itself (so they are not prime nor 1). Also note that 1 is not composite, so a,b must be at least 2 and composite. The problem says solution always exists.
Goal: find any composite a,b with a-b=n.
We need to output numbers up to 1e9, n up to 1e7. So a,b may be as large as 1e9 but we can keep them modest.
Idea: Since n is given, we can set b = some composite number, and a = b + n, also composite. So we need to find composite b such that b + n is also composite.
Alternatively, we could set a = some composite, b = a - n composite.
We need both composite.
We know there are many composites. For small n, we can find small numbers. For large n, we need to ensure both numbers are ≤ 1e9 but that's not a problem because we can choose b large enough but not too large.
Simplify: Look for two consecutive composites? For n=1, we need a and b such that a - b = 1 => consecutive numbers both composite. But are there consecutive composite numbers? Yes, e.g., 8 and 9, 14 and 15, etc. The problem example uses 9 and 8. So for n=1, we can output (9,8) or any other consecutive composites.
For n>1, we could try to find a composite number b such that b and b+n are both composite. Since composite numbers are abundant, we could try b = 4 or 6 or 8 etc. For example, b=4 yields a=4+n. Is 4+n always composite? Not necessarily; if n is such that 4+n is prime, then we need a different b. We can brute force over small b? n up to 1e7, but we can iterate b starting from 4,6,8... up to some limit until both are composite. Since composites are frequent, we can expect to find quickly. But we need to guarantee that we can find within time. b up to maybe a few hundred thousand? Since n is up to 10^7, a = b+n could be up to around 10^7 + small. But a must be ≤ 1e9, so we are fine. The prime density ~ 1/log n, so probability that a random number near 10^7 is prime is ~ 1/ln(10^7) ~ 1/16, so the chance that both b and a are composite is high if we pick b composite. But b is composite by construction; we just need a to be composite. So we could try b=4, check if a=4+n is composite (i.e., not prime). If not, try b=6, then 8,9,10,... We'll quickly find one.
But careful: 1 is not composite, so b must be >=4 (since 2,3 are prime; composite numbers start at 4). So we can start b=4. Check if b+n is composite. However, b+n could be 2? No, b >=4, n>=1 => a >=5. But a could be prime. So we need to test primality of a. Since a ≤ about 10^7 + some thousands, up to maybe 10^8 if b large? Actually we can bound b. To keep efficient, we can limit b up to maybe 10^6 or even 10^5. Testing primality for numbers up to ~10^7 + 10^5 = 10^7+ is easy with trial division up to sqrt, but that could be heavy if many checks. However, we can pre-sieve primes up to some limit? n max 1e7, b we might try up to maybe 100? Because composites are many. Actually, we can use a constructive approach: For any n, we can pick b = 4n? Let's think.
We need a=b+n composite. Suppose we set b = some composite number that ensures a is also composite by construction. For example, we could set b = 4n? Then a = 4n + n = 5n, which is composite if n>1? But if n=1, a=5, which is prime. So not always.
Alternatively, set b = 6n? Then a = 7n, which could be prime if n=1 gives 7 (prime) or if n=some prime? Actually if n=1, 7 is prime; if n=some value such that 7n might be prime if n=1? But if n>1, 7n has factor 7 and n, so it is composite unless n=1? Actually 7n = 7 * n, so it is composite as long as both factors >1. For n>1, 7>1 and n>1, so product is composite. But careful: Could it be that 7n equals a prime? Only if one of the factors is 1. Since 7>1, we need n=1 to be prime? Actually if n=1, product is 7 which is prime. So for n>1, 7n is composite. So for n>=2, b=6n is composite? 6n = 6 * n, composite if n>1? 6n = 6 * n, 6>1, n>1 => product >1 and both >1, so composite? But careful: composite definition: has at least one divisor other than 1 and itself. For a product of two integers both >1, the number is composite, because it has a divisor other than 1 and itself? Actually if both factors are >1, then at least one factor is a proper divisor (not 1 and not the number itself) provided the factors are not equal to the number. For 6n, if n=6, then 66=36, factor 6 is a proper divisor, yes. If n=2, 62=12, factor 2 is proper. If n= some prime p such that 6p, factor 6 is proper (since 6 < 6p unless p=1). So indeed it's composite. However, we must also ensure that b = 6n itself is composite. 6n is composite if n>1? 6n = 6 * n, both >1 => composite. But what about n=1? Then b=6, which is composite anyway (6 is composite). So b=6 works for n=1? For n=1, b=6, a=6+1=7, which is prime, not composite. So fails because a is prime. So we need a composite. For n>1, a=6n+n=7n composite if n>1. But we also need to ensure a composite: if n>1, 7n composite. So for n>=2, (a,b) = (7n, 6n) works? Check: a=7n, b=6n. Are they both composite? For n>=2, 6n composite (since factor 6 or factor 2,3 etc), 7n composite (factor 7). But careful: If n itself may be 1? Not for n>=2. So both are composite. For n=2: a=14, b=12 -> both composite. For n=3: 21 and 18 composite. For n=4: 28 and 24 composite. For n=5: 35 and 30 composite. Works. However, we must also ensure that a,b ≤ 1e9. Since n ≤ 1e7, 7n ≤ 7e7, well within 1e9. So that's fine. So for any n >=2, we can output a=7n, b=6n. This is trivial. But what about n=1? The only problematic case is n=1. We can handle n=1 separately, output e.g., 9 8 as example.
But wait: Are there any other n where this fails? For n=0? Not allowed (n>=1). So n=1 is the only case where n=1 gives a=7, which is prime. So we can have special case for n=1.
But also need to ensure b=6n is composite for n=1? b=6 is composite, that's fine. Only a=7 is prime. So for n=1, we need a different pair.
We can also handle n=1 with e.g., (9,8) or (10,9)? 9 is composite, 8 composite, difference 1. Good.
Thus solution: if n == 1: print "9 8". else: print f"{7n} {6n}".
But is there any case where 6n or 7n might be prime? Let's examine: 6n is composite for all n>=1 because 6n = 2 * 3 * n. If n=1, it's 6 = 23 composite. So b always composite. For a = 7n: For n>1, 7n = 7 * n, so it's composite because it has factors 7 and n (both >1). But wait, if n=7? Then a = 77 = 49 composite. If n is prime, product composite. Only potential issue: if n=1, product is 7 prime. For n=0 not allowed. So n>=2 works. Good.
But also need to ensure that a and b are at least 2. Yes, for n>=2, both >=12? Actually b=6n >=12, a=7n>=14. So fine.
Thus we have a simple solution.
But is there any condition that a and b must be composite, but could they be equal? No, a-b=n>0 so a>b. So fine.
Thus answer: For n=1, output any two consecutive composites like 9 8 or 14 13? Wait 13 is prime, so 14 and 15? 15 composite? 15 composite, 14 composite, diff=1? Actually 15-14=1, both composite. So yes.
But the problem statement says composite: has at least one divisor other than 1 and itself. So 1 is not composite, 2 prime not composite, 3 prime not, 4 composite. So 8 and 9 are composite, good.
Thus we can code easily.
But wait, we must consider that the output constraints: a,b ≤ 1e9. For n up to 1e7, 7n = 7e7 ≤ 1e9, fine.
So the solution is straightforward.
But before finalizing, I recall sometimes such problems require more careful handling: e.g., when n is large, 6n and 7n are composite. But we must ensure that a and b are within bounds, which they are. So it's fine.
Thus final answer: If n==1, print "9 8" else print f"{7n} {6n}".
But let me double-check with examples: Input 512 -> n=512 (>=2), output 7512=3584, 6512=3072. Example output is 4608 4096, which is 9*512? Actually 4608-4096=512. But they output different numbers. So any valid output works; our output would be 3584 3072. But does 3584 and 3072 composite? 3072 is even >2, composite. 3584 is even, composite. So it's valid. So okay.
Thus solution is simple.
But is there any catch about composite definition? They say composite if it has at least one divisor other than 1 and itself. That means numbers like 4,6,8,9,10,... So numbers that are not prime and not 1. So yes.
Our solution for n>=2 yields both even numbers? 6n is even because 6n is multiple of 2. 7n could be odd or even depending on n. If n is even, 7n even; if n odd, 7n odd but composite because factor 7. So all good.
Thus the answer is trivial. But perhaps we need to consider n such that 7n exceeds 1e9? n max 1e7, 7e7 < 1e9, safe.
Now think: Are there any n for which a=7n might equal to 2? No. So it's fine.
Thus solution:
if n == 1:
print("9 8")
else:
print(7n, 6n)
Edge case: n = 2? 72=14 composite, 62=12 composite. Works.
n=3: 21 composite? 21=3*7 composite. 18 composite. Works.
n=4: 28 composite, 24 composite.
n=5: 35 composite, 30 composite.
n=6: 42 composite, 36 composite.
n=7: 49 composite, 42 composite.
n=8: 56 composite, 48 composite.
All fine.
Thus answer is trivial.
But wait, the problem statement might have an implicit requirement that a and b are both ≤ 10^9. For n=1e7, 7e7=70,000,000 which is ≤1e9, so fine.
Double-check the bound: 1 ≤ n ≤ 10^7. So 7n ≤ 7 * 10^7 = 70,000,000, which is less than 10^9. So it's safe.
Thus we can implement.
However, I'm a bit suspicious: The problem says "It can be proven, that solution always exists." And they gave example for 512: 4608 4096. That corresponds to a=9512? Actually 4608 / 512 = 9, 4096/512=8. So they used a=9n, b=8n. That also works for n≥? For n=1, 9 and 8 are composite. So why not simply always output (9n, 8n)? Let's check: For n=1, (9,8) works. For n=2, (18,16) both composite? 18 composite, 16 composite. For n=3, (27,24): 27 = 3^3 composite, 24 composite. For n=4, (36,32) both composite. For n=5, (45,40) both composite. So (9n, 8n) works for all n? Check n=6: (54,48) both composite. n=7: (63,56) both composite. n=8: (72,64) both composite. n=9: (81,72) composite. n=10: (90,80) composite. So indeed, for any positive integer n, 9n and 8n are composite because 9n is divisible by 9 (if n>0) and 9 is composite? Wait, composite means the number itself must be composite. 9n has factor 9, but is 9n necessarily composite? If n=1, 91 = 9, composite? 9 is composite. So yes. For n=1, 9 and 8 are both composite. For n any, 9n: if n=1, 9 composite; if n>1, it has factor 9>1 and also n, so composite. But careful: For 9n to be composite, we need a divisor other than 1 and itself. Since 9n can be written as 9 * n, if both 9 and n are greater than 1, then it's composite. If n=1, 9 is still composite because 9=33. So indeed, 9 is composite. So 9n is always composite? Let's check n=1: 9 composite. n=2: 18 composite. n=3: 27 composite. So yes. Similarly, 8n is composite because 8 is composite? 8 = 2^3, composite. For n=1, 8 composite. So (9n,8n) works for all n>=1. So why would the problem example for n=512 output (4608,4096) which is exactly (9512,8*512)? That suggests a simpler solution: always output (9n, 8n). Indeed, that works for all n. Let's double-check if any n yields 9n prime? 9n prime only if 9n is prime. But 9n = 9 * n, so if n=1, it's 9 which is not prime; if n>1, product of two integers >1, so not prime. So 9n can never be prime because it has factor 3 (since 9=3^2). So it's always composite. Similarly, 8n always has factor 2, so always even >2, thus composite. So indeed (9n, 8n) works for all n. That is even simpler and covers n=1 as well. No special case needed.
But wait, check: For n=1, a=9, b=8 both composite. For n=2, a=18, b=16 composite. So indeed (9n,8n) always valid. Moreover, a-b = 9n-8n = n. So it's a direct solution. So why did they not just say that? Possibly they want to illustrate existence. But the problem statement says "It can be proven that solution always exists." So we can output that.
But is there any constraint that a,b must be ≤ 1e9? For n up to 1e7, 9n = 9e7 = 90,000,000 < 1e9, so fine. So indeed (9n,8n) works for entire input range.
But is there any catch? The only catch could be that 9n or 8n might be equal to 1? No, n≥1 => 8n≥8, so >2. So both are at least 8, which is composite. So they are valid.
Thus the simplest solution: output 9n and 8n.
But wait: The problem says composite if it has at least one divisor other than 1 and itself. So numbers like 4,6,8,9,... So 8 is composite (divisors: 1,2,4,8). 9 composite (1,3,9). So yes.
Thus the solution is just one line: print(9n, 8n).
But why would the example for n=512 output 4608 4096? That's indeed 9512 and 8512. So they actually used this solution. So indeed the intended solution might be to output multiples of 8 and 9.
But wait, the first example for n=1 output 9 8. That's 91, 81. So both examples are consistent with this pattern. So the pattern is exactly that. So the problem is trivial: just output 9n and 8n.
But careful: The output for n=1 is 9 8, not 8 9 because a-b=n => a should be larger. So 9-8=1. So they printed a=9, b=8. So pattern: a = 9n, b = 8n.
Thus the solution is simply:
read n
print(9n, 8n)
But need to ensure a,b are within 10^9: For n=10^7, 9*10^7 = 90,000,000 < 1,000,000,000, fine.
Thus we can implement in any language.
But wait, what about n such that 9n > 10^9? That would be n > floor(1e9/9) ≈ 111,111,111. But n ≤ 10^7, so fine.
Thus final answer: print 9n and 8n.
I'll double-check: The problem statement says "2 ≤ a, b ≤ 10^9". So b=8n must be ≥2. For n=1, b=8, okay. For n=0 not allowed.
Thus the simplest solution is to output (9n, 8n). That covers all n.
But why did I initially think of 7n and 6n? That's also valid for n≥2. But the 9n,8n works for all n including 1. So it's even better, no special case. So I'll go with that.
Thus solution: read integer n, output 9n and 8n.
Now, is there any subtlety? Could there be any n for which 8n is prime? 8n always even and >2, so composite. 9n is divisible by 3, so composite. So it's always fine.
Thus we're done.
But before finalizing, consider the definition of composite: "has at least one divisor other than 1 and itself". For 4, it's composite. For 1, not. For 2, not. For 8, it's composite. For 9, composite. So fine.
Thus code.
Implementation: Python: print(9n, 8n). However, ensure we output as two integers separated by space. In C++: cout << 9n << " " << 8n;
We should be careful about integer overflow? n up to 10^7, 9*n up to 9e7 fits in 32-bit int. So fine.
Thus solution is extremely simple.
But wait, I recall some problem "A. Composite Coloring" or something? This problem is from Codeforces maybe. The typical solution is to output 9n and 8n. Yes, I've seen this problem. So it's correct.
Thus final answer. ```python
import sys
def main():
n = int(sys.stdin.readline().strip())
# Output a = 9n, b = 8n; both are composite for any positive n
print(9 * n, 8 * n)
if name == "main":
main()