import java io import java math import java util public class Class st

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.io.*;
import java.math.*;
import java.util.*;
public class Class {
static boolean isPalindrome(String s) {
int n = s.length();
for (int i = 0; i * 2 < n; ++i) {
if (s.charAt(i) != s.charAt(n - i - 1))
return false;
}
return true;
}
static int[] isMult(int k, int n) {
int ret[] = new int[3];
for (int i = 1; i * i <= k && i < n; ++i) {
if (k % i == 0) {
if (i < n && k / i < n) {
ret[0] = Math.min(i, k / i);
ret[1] = Math.max(i, k / i);
ret[2] = 1;
}
}
}
return ret;
}
public static void main(String[] args) throws IOException
{
//PrintWriter pw = new PrintWriter(new File("output.txt"));
//Scanner sc = new Scanner (new File("input.txt"));
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
if (n == 1) {
pw.println("0 0");
}
else {
for (int i = n * n - 1; i >= 0; --i) {
String s = String.valueOf(i);
if (isPalindrome(s)) {
int ans[] = isMult(i, n);
if (ans[2] == 1) {
pw.println(ans[0] + " " + ans[1]);
sc.close();
pw.flush();
return;
}
}
}
}
sc.close();
pw.flush();
return;
}
}