#include <bits/stdc++.h>
int isprime(int x) {
  int i;
  if (x == 1) return 0;
  for (i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int s[100000] = {0};
  char a[10];
  int i, sum, j, l, n, count = 1;
  for (i = 13; i < 1000000; i++) {
    sum = 0;
    if (isprime(i)) {
      sprintf(a, "%d", i);
      l = strlen(a);
      for (j = l - 1; j >= 0; j--) sum = sum * 10 + a[j] - '0';
      if (isprime(sum) && sum != i) {
        s[count] = i;
        count++;
      }
    }
  }
  while (scanf("%d", &n) != EOF) {
    printf("%d\n", s[n]);
  }
  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>
int isprime(int x) {
  int i;
  if (x == 1) return 0;
  for (i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int s[100000] = {0};
  char a[10];
  int i, sum, j, l, n, count = 1;
  for (i = 13; i < 1000000; i++) {
    sum = 0;
    if (isprime(i)) {
      sprintf(a, "%d", i);
      l = strlen(a);
      for (j = l - 1; j >= 0; j--) sum = sum * 10 + a[j] - '0';
      if (isprime(sum) && sum != i) {
        s[count] = i;
        count++;
      }
    }
  }
  while (scanf("%d", &n) != EOF) {
    printf("%d\n", s[n]);
  }
  return 0;
}

```