#include <bits/stdc++.h>
using namespace std;
bool is_prime[1000500];
vector<long long int> ans;
int main() {
  for (long long int i = 0; i < ((long long int)(1000500)); ++i)
    is_prime[i] = (2 <= i);
  for (long long int i = 0; i < ((long long int)(1000500)); ++i)
    if (is_prime[i])
      for (long long int j = i * i; j < 1000500; j += i) is_prime[j] = false;
  for (long long int i = 0; i < ((long long int)(1000500)); ++i)
    if (is_prime[i]) {
      stringstream ss;
      ss << i;
      string str;
      str = ss.str();
      reverse((str).begin(), (str).end());
      long long int a;
      stringstream ss1;
      ss1 << str;
      ss1 >> a;
      if (i == a) continue;
      if (a < 1000500 && is_prime[a]) ans.push_back(i);
    }
  long long int n;
  cin >> n;
  cout << ans[n - 1] << endl;
}

### 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;
bool is_prime[1000500];
vector<long long int> ans;
int main() {
  for (long long int i = 0; i < ((long long int)(1000500)); ++i)
    is_prime[i] = (2 <= i);
  for (long long int i = 0; i < ((long long int)(1000500)); ++i)
    if (is_prime[i])
      for (long long int j = i * i; j < 1000500; j += i) is_prime[j] = false;
  for (long long int i = 0; i < ((long long int)(1000500)); ++i)
    if (is_prime[i]) {
      stringstream ss;
      ss << i;
      string str;
      str = ss.str();
      reverse((str).begin(), (str).end());
      long long int a;
      stringstream ss1;
      ss1 << str;
      ss1 >> a;
      if (i == a) continue;
      if (a < 1000500 && is_prime[a]) ans.push_back(i);
    }
  long long int n;
  cin >> n;
  cout << ans[n - 1] << endl;
}

```