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 (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>
#include <unistd.h>

typedef unsigned long ulong;

static inline ulong diff(ulong a, ulong b){
    return __builtin_ctzl(a^b);
}
/*
static inline void pl(long n){
#define L 8
    char c[L];
    long i=L-1;
    do{
        c[i]=n%10+'0';
        n/=10;
        i--;
    }while(n>0);
    for(i++;i<L;i++){
        putchar_unlocked(c[i]);
    }
}

static inline void puts_unlocked(const char *s){
    for(size_t i=0; s[i]!='\0'; i++){
        putchar_unlocked(s[i]);
    }
    putchar_unlocked('\n');
}
*/
#define N 17
long data[1<<N];
char buf[819200];
size_t point=0;

static inline void pc(char c){
    buf[point] = c;
    point++;
}
static inline void pl(long n){
#define L 8
    char c[L];
    long i=L-1;
    do{
        c[i]=n%10+'0';
        n/=10;
        i--;
    }while(n>0);
    for(i++;i<L;i++){
        pc(c[i]);
    }
}

static inline void puts_unlocked(const char *s){
    for(size_t i=0; s[i]!='\0'; i++){
        pc(s[i]);
    }
    pc('\n');
}


static void solve(long a, long b, const size_t sp, const size_t ep, long mask){
    if(ep-sp<=2){
        data[sp+0] = a;
        data[sp+1] = b;
        return;
    }
    const ulong d = diff(a, b);
    mask ^= (1<<d);
    const ulong ad = a&(1<<d);
    const ulong bd = b&(1<<d);
    a &= mask;
    b &= mask;
    const ulong ab = a ^ (mask&(-mask));
    const size_t mp = (sp+ep)/2;
    //printf("%ld %ld %ld\n", aa, ab, bb);
    solve(a, ab, sp, mp, mask);
    solve(ab, b, mp, ep, mask);
    for(size_t i=sp; i<mp; i++){ data[i] |= ad; }
    for(size_t i=mp; i<ep; i++){ data[i] |= bd; }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_popcountl(a)%2 == __builtin_popcountl(b)%2){
        puts("NO");
        return 0;
    }
    solve(a, b, 0, 1<<n, 0xFFFFFFFFFFFFFFFF);
    const size_t m = 1<<n;

    puts_unlocked("YES");
    for(size_t i=0; i<m-1; i++){
        pl(data[i]);
        pc(' ');
    }
    pl(data[m-1]);
    pc('\n');
    write(1, buf, point);
    return 0;
}