import java.util.*

private fun check(L: List<Long>, K: Long): Boolean {
    for (i in L.indices) {
        for (j in i + 1 until L.size) {
            if (L[i] != L[j]) continue

            var p = 0L
            for (k in i..j) {
                p = p xor L[k]
            }

            if (p != K) return false
        }
    }
    return true
}

private fun func1(M: Long, K: Long): List<List<Long>> {
    val res = ArrayList<List<Long>>()
    val cnt = Array(1 shl M.toInt()) {0}
    val l = ArrayList<Long>()


    fun rec() {
        if (l.size == 2 shl M.toInt()) {
            if (check(l, K)) {
                res.add(l.clone() as List<Long>)
            }
        }
        for (i in cnt.indices) {
            if (cnt[i] == 2) continue
            cnt[i]++
            l.add(i.toLong())
            rec()
            l.removeAt(l.size - 1)
            cnt[i]--
        }
    }

    rec()

    return res
}

fun main(args: Array<String>) {
    val (M, K) = readLine()!!.split(" ").map{it.toLong()}

    if (M == 1L && K == 1L || K >= 1L shl M.toInt()) {
        println(-1)
        return
    }

    if (M == 1L && K == 0L) {
        println("0 0 1 1")
        return
    }

    val res = ArrayList<Long>()

    val others = (0 until (1L shl M.toInt())).filter { it != K }
    res.addAll(others)
    res.add(K)
    res.addAll(others.reversed())
    res.add(K)

//    if (!check(res, K)) {
//        System.exit(1)
//    }

    println(res.joinToString(" "))
}
