#include <bits/stdc++.h>
using namespace std;
int f[20000];
bool judge(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  f[1] = 13;
  int n = 14, cnt = 1;
  while (1) {
    if (judge(n)) {
      int x = n, y = 0;
      while (x > 0) {
        y = y * 10 + x % 10;
        x /= 10;
      }
      if (y != n && judge(y)) {
        cnt++;
        f[cnt] = n;
      }
    }
    if (cnt == 11184) break;
    n++;
  }
  while (cin >> n) {
    cout << f[n] << endl;
  }
  return 0;
}

### Prompt

Generate a Cpp solution 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;
int f[20000];
bool judge(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  f[1] = 13;
  int n = 14, cnt = 1;
  while (1) {
    if (judge(n)) {
      int x = n, y = 0;
      while (x > 0) {
        y = y * 10 + x % 10;
        x /= 10;
      }
      if (y != n && judge(y)) {
        cnt++;
        f[cnt] = n;
      }
    }
    if (cnt == 11184) break;
    n++;
  }
  while (cin >> n) {
    cout << f[n] << endl;
  }
  return 0;
}

```