#include <bits/stdc++.h>
using namespace std;
int prime[220000];
int p[1100000];
int pk[220000];
bool check(int key) {
  int tmp = 0, Tmp = key;
  while (key) {
    tmp = tmp * 10 + key % 10;
    key /= 10;
  }
  if (tmp == Tmp) return 0;
  if (tmp < 1000000 && !p[tmp]) return 1;
  return 0;
}
int main() {
  int i, j, cnt = 0;
  int v1, v2, tot;
  int tt = 0;
  for (i = 2; 2 * i <= 1000010; i++)
    if (i < 1000000 && !p[i])
      for (j = 2 * i; j < 1000010; j += i) p[j] = i;
  for (i = 2, cnt = 0; i < 1000010; ++i)
    if (i < 1000000 && !p[i]) prime[cnt++] = i;
  for (int i = 0, t = 0; i < cnt; i++) {
    if (check(prime[i])) pk[t++] = prime[i];
  }
  while (scanf("%d", &i) != EOF) {
    printf("%d\n", pk[i - 1]);
  }
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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>
using namespace std;
int prime[220000];
int p[1100000];
int pk[220000];
bool check(int key) {
  int tmp = 0, Tmp = key;
  while (key) {
    tmp = tmp * 10 + key % 10;
    key /= 10;
  }
  if (tmp == Tmp) return 0;
  if (tmp < 1000000 && !p[tmp]) return 1;
  return 0;
}
int main() {
  int i, j, cnt = 0;
  int v1, v2, tot;
  int tt = 0;
  for (i = 2; 2 * i <= 1000010; i++)
    if (i < 1000000 && !p[i])
      for (j = 2 * i; j < 1000010; j += i) p[j] = i;
  for (i = 2, cnt = 0; i < 1000010; ++i)
    if (i < 1000000 && !p[i]) prime[cnt++] = i;
  for (int i = 0, t = 0; i < cnt; i++) {
    if (check(prime[i])) pk[t++] = prime[i];
  }
  while (scanf("%d", &i) != EOF) {
    printf("%d\n", pk[i - 1]);
  }
  return 0;
}

```