CF2234B Palindrome, Twelve and Two Terms
Description
You are given a positive integer $ n $ . A pair of non-negative integers $ a, b $ is called beautiful if the following conditions hold:
- $ a + b = n $ .
- The number $ a $ is a palindrome. $ ^{\text{∗}} $
- The number $ b $ is divisible by $ 12 $ .
You need to find a beautiful pair or report that it does not exist.
$ ^{\text{∗}} $ A number is called a palindrome if and only if it remains the same when its digits (in decimal notation) are written in reverse order. For example, the numbers $ 12321 $ , $ 6776 $ , $ 5 $ , $ 0 $ are palindromes, while the numbers $ 123 $ and $ 69 $ — are not.
Input Format
Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). The description of the test cases follows.
The only line of each test case contains a single integer $ n $ ( $ 1 \leq n \leq 10^{18} $ ).
Output Format
For each test case, if such $ a $ and $ b $ exist, output $ a $ and $ b $ on a separate line, separated by a space. Otherwise, output $ -1 $ on a separate line.
If there are several beautiful pairs $ a, b $ , you may output any of them.
Explanation/Hint
In the first test case, $ a = 1 $ is a palindrome, and $ b = 0 $ is divisible by $ 12 $ , and $ a + b = 1 = n $ , so the answer satisfies the condition.
In the second test case, it can be shown that no pair $ a, b $ is suitable.
In the third test case, $ a = 262 $ is a palindrome, and $ b = 48 $ is divisible by $ 12 $ , and $ a + b = 310 = n $ , so the answer satisfies the condition.