fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #pragma region Macros
  5. #define Faster ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  6. #define ll long long
  7. #define ld long double
  8. #define pii pair<int, int>
  9. #define pll pair<long long, long long>
  10. #define all(x) x.begin(), x.end()
  11. #define rall(x) x.rbegin(), x.rend()
  12. #define pb push_back
  13. #define ff first
  14. #define ss second
  15. #define endl '\n'
  16. #define yes cout << "YES" << endl
  17. #define no cout << "NO" << endl
  18. #define m1 cout << -1 << endl
  19. #pragma endregion
  20.  
  21. #pragma region Math
  22. const ll MOD = 1e9 + 7;
  23. ll gcd(ll a, ll b) { return __gcd(a, b); }
  24. ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
  25. #pragma endregion
  26.  
  27. bool is_palindrome(ll val){
  28. string s1, s2;
  29. s1= to_string(val);
  30. s2=s1;
  31. rall(s2);
  32. if(s1==s2) return 1;
  33. else return 0;
  34. }
  35.  
  36. void solve() {
  37. ll n; cin>>n;
  38. for(int i=0;i<n;i+=12){
  39. ll val=n-i;
  40. if(is_palindrome(val)){
  41. cout<<val<<" "<<i<<endl;
  42. return;
  43. }
  44. }
  45. cout<<-1<<endl;
  46. }
  47.  
  48. int main() {
  49. Faster;
  50. int t = 1;
  51. cin >> t;
  52. while (t--) solve();
  53. return 0;
  54. }
Success #stdin #stdout 0s 5316KB
stdin
6
1
10
310
12
1000000000
6111111111111111
stdout
1 0
10 0
310 0
12 0
1000000000 0
6111111111111111 0