Problem:
Score : 800 points

Problem Statement

You are given integers N,\ A and B.
Determine if there exists a permutation (P_0,\ P_1,\ ...\ P_{2^N-1}) of (0,\ 1,\ ...\ 2^N-1) that satisfies all of the following conditions, and create one such permutation if it exists.

P_0=A

P_{2^N-1}=B

For all 0 \leq i < 2^N-1, the binary representations of P_i and P_{i+1} differ by exactly one bit.

Constraints

1 \leq N \leq 17

0 \leq A \leq 2^N-1

0 \leq B \leq 2^N-1

A \neq B

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

If there is no permutation that satisfies the conditions, print NO.

If there is such a permutation, print YES in the first line.
Then, print (P_0,\ P_1,\ ...\ P_{2^N-1}) in the second line, with spaces in between.
If there are multiple solutions, any of them is accepted.

Sample Input 1

2 1 3

Sample Output 1

YES
1 0 2 3

The binary representation of P=(1,0,2,3) is (01,00,10,11), where any two adjacent elements differ by exactly one bit.

Sample Input 2

3 2 1

Sample Output 2

NO

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


vector<int> v[20];
int main(){
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	a^=b;
	if(__builtin_popcount(a)%2==0){
		cout<<"NO"<<endl;
		return 0;
	}
	int all=1<<n;
	rep(i,n)v[i].resize(all);
	rep(i,n){
		int cur=0;
		rep(j,all){
			if((j%(1<<i))==0&&(j%(1<<(i+1)))!=0)cur=1-cur;
			v[i][j]=cur;
		}
	}
	int x=0;
	while(((1<<x)&a)==0)++x;
	swap(v[n-1],v[x]);
	rep(i,all)v[x][i]=1-v[x][i];
	int y=x+1,z=x;
	vector<int> ans(all);
	rep(i,all){
		rep(j,n)ans[i]+=(1<<j)*v[j][i];
	}
	vector<int> pos(all);
	rep(i,all)pos[ans[i]]=i;
	while(1){
		y=z+1;
		while(y<n&&((1<<y)&a)==0)++y;
		if(y==n)break;
		z=y+1;
		while(z<n&&((1<<z)&a)==0)++z;
		int i=0;
		while((ans[i]>>z)%2==(ans[i]>>y)%2){
			int nxt=ans[i]+(1<<y)+(1<<z);
			int idx=pos[nxt];
			swap(pos[nxt],pos[ans[i]]);
			swap(ans[idx],ans[i]);
			++i;
		}
	}
	cout<<"YES"<<endl;
	rep(i,all)cout<<(ans[i]^b)<<" ";
	cout<<endl;
	return 0;
}