#include <bits/stdc++.h>
using namespace std;
vector<int> pl, res;
map<int, bool> isprime;
bool np[2000001];
int main(int argc, char **argv) {
  for (int i = (2); i < (1416); ++i)
    if (!np[i]) {
      isprime[i] = 1;
      pl.push_back(i);
      for (long long j = (long long)i * i; j <= 2000000; j += i) np[j] = 1;
    }
  for (int j = (1415); j < (2000001); ++j)
    if (!np[j]) {
      pl.push_back(j), isprime[j] = 1;
    }
  for (int i = (0); i < (pl.size()); ++i) {
    int j = pl[i], k = 0;
    while (j) k = k * 10 + j % 10, j /= 10;
    if (isprime[k] && pl[i] != k) res.push_back(pl[i]);
  }
  int n;
  cin >> n;
  cout << res[n - 1] << endl;
  return 0;
}

### Prompt

Create a solution in CPP for 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;
vector<int> pl, res;
map<int, bool> isprime;
bool np[2000001];
int main(int argc, char **argv) {
  for (int i = (2); i < (1416); ++i)
    if (!np[i]) {
      isprime[i] = 1;
      pl.push_back(i);
      for (long long j = (long long)i * i; j <= 2000000; j += i) np[j] = 1;
    }
  for (int j = (1415); j < (2000001); ++j)
    if (!np[j]) {
      pl.push_back(j), isprime[j] = 1;
    }
  for (int i = (0); i < (pl.size()); ++i) {
    int j = pl[i], k = 0;
    while (j) k = k * 10 + j % 10, j /= 10;
    if (isprime[k] && pl[i] != k) res.push_back(pl[i]);
  }
  int n;
  cin >> n;
  cout << res[n - 1] << endl;
  return 0;
}

```