import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  // val a = new Array[Int](N)

  val M = in.next().toInt
  var K = in.next().toInt
  if (K == 0) {
    for (i <- 0 until 1 << M) {
      if (i == 0) {
        pw.print("0 0")
      }
      else
        pw.print(s" $i $i")
    }
    pw.println()
  }
  else {
    var hoge = 0
    var num = -1
    val k = K
    breakable {
      while(K > 0) {
        if(K == 1) {
          num = hoge
          break
        }
        else {
          if(K % 2 != 0)
            break
          else {
            K = K / 2
            num += 1
          }
        }
      }
    }

    if(num == -1)
      pw.println(-1)
    else if ((1<<M)-1 >= k){
      val a = (1<<M)

      if(K == 1) {
        for (i <- 0 until (1<<M) / 4) {
          if(i == 0) {
            pw.print(s"${4*i} ${4*i + 1} ${4*i+2} ${4*i+3}")
            pw.print(s" ${4*i+1} ${4*i} ${4*i+3} ${4*i+2}")
          }
          else {
            pw.print(s" ${4*i} ${4*i + 1} ${4*i+2} ${4*i+3}")
            pw.print(s" ${4*i+1} ${4*i} ${4*i+3} ${4*i+2}")
          }
        }
        pw.println()
      }
      else {
        for (i <- 0 until (1<<M) / 4) {
          if(i == 0) {
            pw.print(s"${4*i} ${4*i + k} ${4*i+1} ${4*i+1 + k}")
            pw.print(s" ${4*i + k} ${4*i} ${4*i+1 + k} ${4*i+1}")
          }
          else {
            pw.print(s" ${4*i} ${4*i + k} ${4*i+1} ${4*i+1 + k}")
            pw.print(s" ${4*i + k} ${4*i} ${4*i+1 + k} ${4*i+1}")
          }
        }
        pw.println()
      }
    }
  }
    

  pw.flush()
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
