#include <bits/stdc++.h>
using namespace std;
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long b, long long e, long long m) {
  b %= m;
  long long ans = 1;
  for (; e; b = b * b % m, e /= 2)
    if (e & 1) ans = ans * b % m;
  return ans;
}
const int N = 100100;
int res[N];
void go(vector<pair<int, int> > pos, vector<pair<int, int> > ma) {
  assert(((int)pos.size()) == ((int)ma.size()));
  if (!((int)pos.size())) return;
  for (int i = 0; i < (((int)pos.size())); ++i) {
    pos[i].first /= 2;
    ma[i].first /= 2;
  }
  int big = 0;
  for (auto it : pos) big = max(big, it.first);
  if (!big || ((int)pos.size()) == 1) {
    for (int i = 0; i < (((int)pos.size())); ++i) {
      res[ma[i].second] = pos[i].second;
    }
    return;
  }
  vector<pair<int, int> > P, I;
  vector<pair<int, int> > P2, I2;
  vector<pair<int, int> > zer1, zer2;
  for (int i = 0; i < ((int)pos.size()); i++) {
    if (pos[i].first == 0) {
      zer1.push_back(pos[i]);
    } else if (pos[i].first % 2 == 1)
      I.push_back(pos[i]);
    else
      P.push_back(pos[i]);
    if (ma[i].first == 0) {
      zer2.push_back(ma[i]);
    } else if (ma[i].first % 2 == 1)
      I2.push_back(ma[i]);
    else
      P2.push_back(ma[i]);
  }
  while (((int)P.size()) != ((int)I2.size()) ||
         ((int)I.size()) != ((int)P2.size())) {
    if (((int)P.size()) < ((int)I2.size())) {
      assert(zer1.size());
      P.push_back(zer1.back());
      zer1.pop_back();
    }
    if (((int)P.size()) > ((int)I2.size())) {
      assert(((int)zer2.size()));
      I2.push_back(zer2.back());
      zer2.pop_back();
    }
    if (((int)I.size()) < ((int)P2.size())) {
      assert(zer1.size());
      I.push_back(zer1.back());
      zer1.pop_back();
    }
    if (((int)I.size()) > ((int)P2.size())) {
      assert(((int)zer2.size()));
      P2.push_back(zer2.back());
      zer2.pop_back();
    }
  }
  while (((int)zer1.size())) {
    assert(((int)zer2.size()));
    if (((int)I.size()) % 2 == 1) {
      I.push_back(zer1.back());
      zer1.pop_back();
      P2.push_back(zer2.back());
      zer2.pop_back();
    } else {
      P.push_back(zer1.back());
      zer1.pop_back();
      I2.push_back(zer2.back());
      zer2.pop_back();
    }
  }
  assert(((int)zer2.size()) == 0);
  go(I, P2);
  go(P, I2);
}
void solve1(int n) {
  if (n % 2 == 1) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
  vector<pair<int, int> > P, I;
  for (int i = 1; i < (n + 1); ++i) {
    if (i % 2 == 1)
      I.push_back(pair<int, int>(i, i));
    else
      P.push_back(pair<int, int>(i, i));
  }
  go(I, P);
  go(P, I);
  for (int i = 1; i <= n; i++) {
    assert(i != res[i]);
    assert((i & res[i]) == 0);
    cout << res[i] << " \n"[i == n];
  }
}
void shift(vector<int>& v, int k) {
  vector<int> res;
  for (int i = k; i < ((int)v.size()); i++) res.push_back(v[i]);
  for (int i = 0; i < k; i++) res.push_back(v[i]);
  v = res;
}
set<int> grupo[20];
void solve2(int n) {
  for (int j = 0; j < (20); ++j) grupo[j].clear();
  for (int i = 1; i <= n; i++) {
    int j = 0;
    for (int k = 0; k < (20); ++k)
      if ((1 << k) & i) j = k;
    grupo[j].insert(i);
  }
  int last = 0;
  for (int k = 0; k < (20); ++k)
    if (((int)grupo[k].size())) last = k;
  int some = 0;
  for (int k = 1; k < (last + 1); ++k) {
    if (((int)grupo[k].size()) < 2) {
      cout << "NO"
           << "\n";
      return;
    } else if (((int)grupo[k].size()) > 2) {
      some = k;
    }
  }
  if (!some) {
    cout << "NO"
         << "\n";
    return;
  }
  int x = (1 << some) + 1;
  grupo[some].erase(x);
  res[x] = 1;
  res[1] = x;
  for (int i = 1; i <= last; i++) {
    vector<int> here;
    for (int j : grupo[i]) here.push_back(j);
    for (int j = 0; j < ((int)here.size()); j++) {
      res[here[j]] = here[(j + 1) % ((int)here.size())];
    }
  }
  cout << "YES\n";
  set<int> S;
  for (int i = 1; i <= n; i++) {
    assert(res[i] != 0);
    assert((res[i] & i) != 0);
    S.insert(i);
    cout << res[i] << " \n"[i == n];
  }
  assert(((int)S.size()) == n);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  solve1(n);
  solve2(n);
}

### Prompt

Please provide a cpp coded solution to the problem described below:

Given an integer N, find two permutations:

  1. Permutation p of numbers from 1 to N such that pi ≠ i and pi & i = 0 for all i = 1, 2, ..., N. 
  2. Permutation q of numbers from 1 to N such that qi ≠ i and qi & i ≠ 0 for all i = 1, 2, ..., N. 



& is the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).

Input

The input consists of one line containing a single integer N (1 ≤ N ≤ 105).

Output

For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.

Examples

Input

3


Output

NO
NO


Input

6


Output

YES
6 5 4 3 2 1 
YES
3 6 2 5 1 4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long b, long long e, long long m) {
  b %= m;
  long long ans = 1;
  for (; e; b = b * b % m, e /= 2)
    if (e & 1) ans = ans * b % m;
  return ans;
}
const int N = 100100;
int res[N];
void go(vector<pair<int, int> > pos, vector<pair<int, int> > ma) {
  assert(((int)pos.size()) == ((int)ma.size()));
  if (!((int)pos.size())) return;
  for (int i = 0; i < (((int)pos.size())); ++i) {
    pos[i].first /= 2;
    ma[i].first /= 2;
  }
  int big = 0;
  for (auto it : pos) big = max(big, it.first);
  if (!big || ((int)pos.size()) == 1) {
    for (int i = 0; i < (((int)pos.size())); ++i) {
      res[ma[i].second] = pos[i].second;
    }
    return;
  }
  vector<pair<int, int> > P, I;
  vector<pair<int, int> > P2, I2;
  vector<pair<int, int> > zer1, zer2;
  for (int i = 0; i < ((int)pos.size()); i++) {
    if (pos[i].first == 0) {
      zer1.push_back(pos[i]);
    } else if (pos[i].first % 2 == 1)
      I.push_back(pos[i]);
    else
      P.push_back(pos[i]);
    if (ma[i].first == 0) {
      zer2.push_back(ma[i]);
    } else if (ma[i].first % 2 == 1)
      I2.push_back(ma[i]);
    else
      P2.push_back(ma[i]);
  }
  while (((int)P.size()) != ((int)I2.size()) ||
         ((int)I.size()) != ((int)P2.size())) {
    if (((int)P.size()) < ((int)I2.size())) {
      assert(zer1.size());
      P.push_back(zer1.back());
      zer1.pop_back();
    }
    if (((int)P.size()) > ((int)I2.size())) {
      assert(((int)zer2.size()));
      I2.push_back(zer2.back());
      zer2.pop_back();
    }
    if (((int)I.size()) < ((int)P2.size())) {
      assert(zer1.size());
      I.push_back(zer1.back());
      zer1.pop_back();
    }
    if (((int)I.size()) > ((int)P2.size())) {
      assert(((int)zer2.size()));
      P2.push_back(zer2.back());
      zer2.pop_back();
    }
  }
  while (((int)zer1.size())) {
    assert(((int)zer2.size()));
    if (((int)I.size()) % 2 == 1) {
      I.push_back(zer1.back());
      zer1.pop_back();
      P2.push_back(zer2.back());
      zer2.pop_back();
    } else {
      P.push_back(zer1.back());
      zer1.pop_back();
      I2.push_back(zer2.back());
      zer2.pop_back();
    }
  }
  assert(((int)zer2.size()) == 0);
  go(I, P2);
  go(P, I2);
}
void solve1(int n) {
  if (n % 2 == 1) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
  vector<pair<int, int> > P, I;
  for (int i = 1; i < (n + 1); ++i) {
    if (i % 2 == 1)
      I.push_back(pair<int, int>(i, i));
    else
      P.push_back(pair<int, int>(i, i));
  }
  go(I, P);
  go(P, I);
  for (int i = 1; i <= n; i++) {
    assert(i != res[i]);
    assert((i & res[i]) == 0);
    cout << res[i] << " \n"[i == n];
  }
}
void shift(vector<int>& v, int k) {
  vector<int> res;
  for (int i = k; i < ((int)v.size()); i++) res.push_back(v[i]);
  for (int i = 0; i < k; i++) res.push_back(v[i]);
  v = res;
}
set<int> grupo[20];
void solve2(int n) {
  for (int j = 0; j < (20); ++j) grupo[j].clear();
  for (int i = 1; i <= n; i++) {
    int j = 0;
    for (int k = 0; k < (20); ++k)
      if ((1 << k) & i) j = k;
    grupo[j].insert(i);
  }
  int last = 0;
  for (int k = 0; k < (20); ++k)
    if (((int)grupo[k].size())) last = k;
  int some = 0;
  for (int k = 1; k < (last + 1); ++k) {
    if (((int)grupo[k].size()) < 2) {
      cout << "NO"
           << "\n";
      return;
    } else if (((int)grupo[k].size()) > 2) {
      some = k;
    }
  }
  if (!some) {
    cout << "NO"
         << "\n";
    return;
  }
  int x = (1 << some) + 1;
  grupo[some].erase(x);
  res[x] = 1;
  res[1] = x;
  for (int i = 1; i <= last; i++) {
    vector<int> here;
    for (int j : grupo[i]) here.push_back(j);
    for (int j = 0; j < ((int)here.size()); j++) {
      res[here[j]] = here[(j + 1) % ((int)here.size())];
    }
  }
  cout << "YES\n";
  set<int> S;
  for (int i = 1; i <= n; i++) {
    assert(res[i] != 0);
    assert((res[i] & i) != 0);
    S.insert(i);
    cout << res[i] << " \n"[i == n];
  }
  assert(((int)S.size()) == n);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  solve1(n);
  solve2(n);
}

```