#include <bits/stdc++.h>
int ss(int x) {
  if (x == 1)
    return 0;
  else {
    int n, i;
    for (i = 2; i * i <= x; i++) {
      if (x % i == 0) return 0;
    }
    return 1;
  }
}
int turn(int x) {
  int y = 0;
  while (x) {
    y = y * 10 + x % 10;
    x /= 10;
  }
  return y;
}
int a[20000];
int main() {
  int i, sum = 0;
  for (i = 2;; i++) {
    if (ss(turn(i)) && i != turn(i) && ss(i)) {
      sum++;
      a[sum] = i;
    }
    if (sum == 11184) break;
  }
  int d;
  while (~scanf("%d", &d)) printf("%d\n", a[d]);
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.

Input

jxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1 ≤ d ≤ 11184) — jxu edu-rqiut ydtun ev jxu ucyhf je vydt.

Output

ekjfkj q iydwbu dkcruh.

Examples

Input

1


Output

13

### Response

```cpp
#include <bits/stdc++.h>
int ss(int x) {
  if (x == 1)
    return 0;
  else {
    int n, i;
    for (i = 2; i * i <= x; i++) {
      if (x % i == 0) return 0;
    }
    return 1;
  }
}
int turn(int x) {
  int y = 0;
  while (x) {
    y = y * 10 + x % 10;
    x /= 10;
  }
  return y;
}
int a[20000];
int main() {
  int i, sum = 0;
  for (i = 2;; i++) {
    if (ss(turn(i)) && i != turn(i) && ss(i)) {
      sum++;
      a[sum] = i;
    }
    if (sum == 11184) break;
  }
  int d;
  while (~scanf("%d", &d)) printf("%d\n", a[d]);
  return 0;
}

```