#include <bits/stdc++.h>
long int a[1000009], ans[1000009];
void seive() {
  long int i, j, n, d, x, r, p, l, z = 1, s;
  memset(a, 0, sizeof(a));
  a[0] = a[1] = 1;
  for (i = 2; i <= 1000000; i++) {
    if (a[i] == 0) {
      for (j = i + i; j <= 1000000; j += i) {
        a[j] = 1;
      }
    }
  }
  p = 1;
  for (i = 13; i <= 1000000; i++) {
    if (a[i] == 0) {
      n = i;
      s = 0;
      while (n != 0) {
        r = n % 10;
        n /= 10;
        s = s * 10 + r;
      }
      if (s != i) {
        if (a[s] == 0) {
          ans[p] = i;
          p++;
        }
      }
    }
  }
}
int main() {
  long int n, r;
  seive();
  while (scanf("%ld", &n) != EOF) {
    printf("%ld\n", ans[n]);
  }
  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>
long int a[1000009], ans[1000009];
void seive() {
  long int i, j, n, d, x, r, p, l, z = 1, s;
  memset(a, 0, sizeof(a));
  a[0] = a[1] = 1;
  for (i = 2; i <= 1000000; i++) {
    if (a[i] == 0) {
      for (j = i + i; j <= 1000000; j += i) {
        a[j] = 1;
      }
    }
  }
  p = 1;
  for (i = 13; i <= 1000000; i++) {
    if (a[i] == 0) {
      n = i;
      s = 0;
      while (n != 0) {
        r = n % 10;
        n /= 10;
        s = s * 10 + r;
      }
      if (s != i) {
        if (a[s] == 0) {
          ans[p] = i;
          p++;
        }
      }
    }
  }
}
int main() {
  long int n, r;
  seive();
  while (scanf("%ld", &n) != EOF) {
    printf("%ld\n", ans[n]);
  }
  return 0;
}

```