#include <bits/stdc++.h>
using namespace std;
char *my_strrev(char *str) {
  char *right = str;
  char *left = str;
  char ch;
  while (*right) right++;
  right--;
  while (left < right) {
    ch = *left;
    *left++ = *right;
    *right-- = ch;
  }
  return (str);
}
const int maxn = 999999 + 1;
bool isntPrime[maxn] = {true, true};
vector<int> Primes;
set<int> Emirps;
int main(void) {
  int n = 999999;
  for (int i = 2; i != n; ++i)
    if (!isntPrime[i]) {
      if (i == 3) i = 3;
      Primes.push_back(i);
      for (int j = 2 * i; j < n; j += i) isntPrime[j] = true;
    }
  for (int i = 0; i < Primes.size(); i++) {
    char c[31];
    sprintf(c, "%d", Primes[i]);
    char *d = my_strrev(c);
    int tmp = atoi(d);
    if (!isntPrime[tmp] && tmp != Primes[i]) Emirps.insert(tmp);
  }
  int t;
  while (cin >> t) {
    int i = 0;
    for (set<int>::iterator it = Emirps.begin(); it != Emirps.end();
         it++, i++) {
      if (i == t - 1) cout << *it << 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;
char *my_strrev(char *str) {
  char *right = str;
  char *left = str;
  char ch;
  while (*right) right++;
  right--;
  while (left < right) {
    ch = *left;
    *left++ = *right;
    *right-- = ch;
  }
  return (str);
}
const int maxn = 999999 + 1;
bool isntPrime[maxn] = {true, true};
vector<int> Primes;
set<int> Emirps;
int main(void) {
  int n = 999999;
  for (int i = 2; i != n; ++i)
    if (!isntPrime[i]) {
      if (i == 3) i = 3;
      Primes.push_back(i);
      for (int j = 2 * i; j < n; j += i) isntPrime[j] = true;
    }
  for (int i = 0; i < Primes.size(); i++) {
    char c[31];
    sprintf(c, "%d", Primes[i]);
    char *d = my_strrev(c);
    int tmp = atoi(d);
    if (!isntPrime[tmp] && tmp != Primes[i]) Emirps.insert(tmp);
  }
  int t;
  while (cin >> t) {
    int i = 0;
    for (set<int>::iterator it = Emirps.begin(); it != Emirps.end();
         it++, i++) {
      if (i == t - 1) cout << *it << endl;
    }
  }
  return 0;
}

```