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: Runtime Error)

	//     . .. ... ..... be naame khodaa ..... .... ... .. .     \\

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

inline int in(){int x, y; y = scanf("%d", &x); return x;}

const int N = 22;

void revxor(vector <int> &a, int x) {
	vector <int> b = a;
	reverse(b.begin(), b.end());
	for(int y : b)
		a.push_back(y ^ x);
}

vector <int> get(int n, int mask, int fixMask, int st, bool khare) {
	if(st == n) {
		vector <int> res;
		res.push_back(mask);
		return res;
	}
	if(fixMask >> st & 1)
		return get(n, mask, fixMask, st + 1, khare);
	vector <int> L = get(n, mask, fixMask, st + 1, khare);
	revxor(L, (1 << st));
	if(khare)
		reverse(L.begin(), L.end());
	cerr << n << ", " << mask << ", " << fixMask << ", " << st << ": ";
	for(int x : L)
		cerr << x << " ";
	cerr << endl;
	return L;
}

vector <int> solve(int n, int st, vector <int> bits, int mask = 0, int fixMask = 0, bool khare = false) {
	if(st == 0) {
		int i =	bits[st];
		cerr << "ST: " << i << endl;
		vector <int> A = solve(n, st + 1, bits, mask, fixMask | (1 << i), false);
		vector <int> B = A;
		reverse(B.begin(), B.end());
		
		for(int &x : B)
			x ^= (1 << bits[st]);
		for(int i = 1; i < bits.size(); i += 2) {
			int a = bits[i];
			int b = bits[i + 1];
			for(int &x : B) {
				x ^= (1 << bits[st]);
				if((x >> b & 1) && (x >> a & 1)==0)
					continue;
				x ^= (1 << a);
				x ^= (1 << b);
			}
		}
//		cerr << "ST -" << endl;
//		vector <int> B = solve(n, st + 1, bits, mask | (1 << i), fixMask | (1 << i), true);
		for(int x : B)
			A.push_back(x);
		return A;
	}
	if(st == bits.size()){
		vector <int> A = get(n, mask, fixMask, 0, false);
		if(khare && bits.size()<3)
			reverse(A.begin(), A.end());
		return A;
	}
	int i =	bits[st];
	int j = bits[st + 1];
	cerr << "Here! " <<  i << ", " << j << endl;
	vector <int> A;
	if(khare == false) {
		A = solve(n, st + 2, bits, mask, (fixMask | (1 << i) | (1 << j)), khare);
		revxor(A, (1 << i));
		revxor(A, (1 << j));
	}
	else {
		A = solve(n, st + 2, bits, mask | (1 << j), (fixMask | (1 << i) | (1 << j)), khare);
		revxor(A, (1 << j));
		revxor(A, (1 << i));
	}
	cerr << i << " => ";
	for(int x : A)
		cerr << x << " ";
	cerr << endl;
	return A;
}

int main() {
	int n = in(), a = in(), b = in();
	int c = a^b;
	if(__builtin_popcount(c) % 2 == 0) {
		cout << "NO\n";
		return 0;
	}
	int en = c;
	vector <int> bits;
	int chi = 0;
	for(int i = 0; i < n; i++) {
		if(c >> i & 1) {
			if(bits.size() % 2 == 0)
				chi |= (1 << i);
			bits.push_back(i);
		}
	}
//	for(int i : bits)
//		cerr << i << endl;
	chi ^= (1 << bits.back());
	vector <int> res = solve(n, 0, bits);
	cout << "YES\n";
	int las = -1;
	for(int x : res) {
		int cur = (x ^ a);
		cout << cur << " ";
		if(las != -1) {
			assert(__builtin_popcount(las ^ cur) == 1);
		}
		las = cur;
	}
	cout << endl;
}