Problem: D: XORANDORBAN

Problem Statement

You are given a positive integer N. Your task is to determine a set S of 2^N integers satisfying the following conditions:

* All the integers in S are at least 0  and less than 2^{N+1}.
* All the integers in S are distinct.
* You are also given three integers X, A, and O, where 0 \leq X, A, O < 2^{N+1}. Then, any two integers (a, b) in S must satisfy a {\it xor} b \neq X, a {\it and} b \neq A, a {\it or} b \neq O, where {\it xor}, {\it and}, {\it or} are bitwise xor, bitwise and, bitwise or, respectively. Note that a and b are not necessarily different.



Input


N X A O

Constraints

* 1 \leq N \leq 13
* 0 \leq X, A, O < 2^{N+1}
* Inputs consist only of integers.



Output

If there is no set satisfying the conditions mentioned in the problem statement, output `No` in a line. Otherwise, output `Yes` in the first line, and then output 2^N integers in such a set in the second line. If there are multiple sets satisfying the conditions, you can output any of them.

Sample Input 1


2 6 1 5

Output for Sample Input 1


Yes
0 3 4 7


Sample Input 2


3 0 5 1

Output for Sample Input 2


No

Sample Input 3


3 4 2 5

Output for Sample Input 3


Yes
1 0 6 15 8 9 14 7






Example

Input

2 6 1 5


Output

Yes
0 3 4 7

Solution (in CPP):

Solution:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

struct graph {
private:
	int n;
	vector<vector<int>> G, rG;
	vector<bool> used;
	vector<int> vs;

	int mk;
	vector<vector<int>> fG;
	vector<vector<int>> ori;
	vector<int> trans;
public:
	graph(int sz) {
		n = sz;
		G.resize(n);
		rG.resize(n);
		used.resize(n);

		fG.resize(n);
		trans.resize(n, -1);
		ori.resize(n);
	}
	void add_edge(int a, int b) {
		G[a].push_back(b);
		rG[b].push_back(a);
	}
	void dfs(int v) {
		used[v] = true;
		rep(i, G[v].size()) {
			if (!used[G[v][i]])dfs(G[v][i]);
		}
		vs.push_back(v);
	}
	void rdfs(int v, int k) {
		used[v] = true;
		queue<int> q; q.push(v);
		vector<int> c;
		while (!q.empty()) {
			int id = q.front(); q.pop();
			ori[k].push_back(id);
			rep(j, rG[id].size()) {
				int to = rG[id][j];
				if (used[to]) {
					if (trans[to] >= 0)c.push_back(trans[to]);
					continue;
				}
				used[to] = true; q.push(to);
			}
		}
		sort(c.begin(), c.end());
		int len = unique(c.begin(), c.end()) - c.begin();
		rep(i, len) {
			fG[c[i]].push_back(k);
		}
		rep(i, ori[k].size()) {
			trans[ori[k][i]] = k;
		}
	}
	void scc() {
		fill(used.begin(), used.end(), false);
		rep(i, n) {
			if (!used[i])dfs(i);
		}
		fill(used.begin(), used.end(), false);
		int k = 0;
		per(i, (int)vs.size()) {
			if (!used[vs[i]]) {
				rdfs(vs[i], k); k++;
			}
		}
		mk = k;
	}
	vector<int> query(int x) {
		vector<int> ret;
		vector<bool> ban(mk, false);
		rep(i, mk) {
			rep(j, ori[i].size()) {
				int t = ori[i][j];
				if (trans[t^x] == i)ban[i] = true;
			}
		}
		per(i, mk) {
			if (ban[i])continue;
			//cout << i << endl;
			rep(j, ori[i].size()) {
				int cur = ori[i][j];
				ret.push_back(cur);
				int iid = trans[cur^x];
				ban[iid] = true;
			}
		}
		return ret;
	}
};

void solve() {
	int n, x, a, o;
	cin >> n >> x >> a >> o;
	if (x == 0) {
		cout << "No" << endl; return;
	}
	int sup = 1 << (n + 1);
	graph g(sup);
	rep(i, sup) {
		if ((a&i) == a) {
			vector<int> v;
			rep(j, n + 1) {
				if ((i&(1 << j)) == 0) {
					v.push_back(j);
				}
			}
			int len = v.size();
			rep(j, 1 << len) {
				int ss = 0;
				rep(k, len) {
					if (j&(1 << k)) {
						ss += 1<<v[k];
					}
				}
				ss += a;
				//cout << i << " " << ss << endl;
				g.add_edge(i, ss^x);
				g.add_edge(ss, i^x);
			}
		}
	}
	rep(i, sup) {
		int aa = 0;
		vector<int> v;
		bool pass = false;
		rep(j, n + 1) {
			if (o&(1 << j)) {
				if (i&(1 << j)) {
					v.push_back(j);
				}
				else {
					aa += 1 << j;
				}
			}
			else {
				if (i&(1 << j)) {
					pass = true;
				}
			}
		}
		if (pass)continue;
		int len = v.size();
		rep(j, 1 << len) {
			int ss = 0;
			rep(k, len) {
				if (j&(1 << k)) {
					ss += 1 << v[k];
				}
			}
			ss += aa;
			//cout << i << " " << ss << endl;
			g.add_edge(i, ss^x);
			g.add_edge(ss, i^x);
		}
	}
	g.scc();
	vector<int> ans = g.query(x);
	//cout << ans.size() << endl;
	if (ans.size() >= (1 << n)) {
		cout << "Yes" << endl;
		rep(i, (1 << n)) {
			if (i > 0)cout << " ";
			cout << ans[i];
		}
		cout << endl;
	}
	else {
		cout << "No" << endl;
	}

}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(50);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}