Under construction

Still being built. Things may change

Partitioning

Time limit0.5sMemory limit512 MB

Summary
Decide whether the set {0,...,2^N-1} splits into two subsets of sizes K and 2^N-K, each closed under bitwise OR, and print one split if it exists.
Level

Medium7 of 10

Topics
Bit manipulation, Combinatorics, Math, Brute force
Solved
No attempts yet

Problem

For a set SS, call SS a good set when a,b∈S⟹(a∣b)∈Sa,b \in S \Longrightarrow (a \mid b) \in S holds, and only then. Here ∣\mid denotes bitwise-or. For example, {1,3}\{1, 3\} is a good set, because (1∣1)=1(1 \mid 1) = 1, (1∣3)=3(1 \mid 3) = 3, and (3∣3)=3(3 \mid 3) = 3 are all elements of {1,3}\{1, 3\}. However, (1∣2)=3(1 \mid 2) = 3, so {1,2}\{1, 2\} is not a good set.

For a subset AA of the universe U={0,1,⋯ ,2N−1}U = \{0, 1, \cdots, 2^N - 1\}, call AA an N,KN, K-partition when AA has KK elements and both AA and U∖AU \setminus A are good sets, and only then.

Given NN and KK, write a program that determines whether an N,KN, K-partition exists and, if it does, prints an example of one.

Input

The first line gives the natural numbers NN and KK separated by a space.

Output

If no N,KN, K-partition exists, print NO on the first line.

If an N,KN, K-partition exists, print YES on the first line. On the second line, print the elements of an N,KN, K-partition in increasing order.

If multiple N,KN, K-partitions exist, printing any one of them is accepted.

Constraints

Every input satisfies the following conditions.

  • 1≤N≤121 \le N \le 12
  • 1≤K≤2N1 \le K \le 2^N

Examples4

  1. Example 1

    Input
    1 1
    
    Expected output
    YES
    0
    
  2. Example 2

    Input
    2 4
    
    Expected output
    YES
    0 1 2 3
    
  3. Example 3

    Input
    3 3
    
    Expected output
    YES
    1 4 5
    
  4. Example 4

    Input
    3 5
    
    Expected output
    YES
    0 2 3 6 7