#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1000000, MaxC = 0x3F3F3F3F, NA = -1;
bool s[MaxN];
int p[MaxN];
int m, n;
int main(void) {
  int i, j, k;
  memset(s, 1, sizeof(s));
  s[0] = s[1] = false;
  for (i = 2; i * i < MaxN; i++)
    if (s[i])
      for (j = i * i; j < MaxN; j += i) s[j] = false;
  m = 0;
  for (i = 0; i < MaxN; i++)
    if (s[i]) {
      for (j = i, k = 0; j > 0; j /= 10) k = k * 10 + j % 10;
      if (k != i && s[k]) p[m++] = i;
    }
  while (scanf(" %d", &n) != EOF) {
    printf("%d\n", p[n - 1]);
  }
  return 0;
}

### Prompt

Please create a solution in cpp to the following problem:

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;
const int MaxN = 1000000, MaxC = 0x3F3F3F3F, NA = -1;
bool s[MaxN];
int p[MaxN];
int m, n;
int main(void) {
  int i, j, k;
  memset(s, 1, sizeof(s));
  s[0] = s[1] = false;
  for (i = 2; i * i < MaxN; i++)
    if (s[i])
      for (j = i * i; j < MaxN; j += i) s[j] = false;
  m = 0;
  for (i = 0; i < MaxN; i++)
    if (s[i]) {
      for (j = i, k = 0; j > 0; j /= 10) k = k * 10 + j % 10;
      if (k != i && s[k]) p[m++] = i;
    }
  while (scanf(" %d", &n) != EOF) {
    printf("%d\n", p[n - 1]);
  }
  return 0;
}

```