import Main.Dinic.Edge

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
object Main extends App {
  import scala.io.StdIn._

  val Array(n, w) = readLine.trim.split(' ').map(_.toInt)
  val aNumbers = readLine.trim.split(' ').map(_.toInt)
  val bNumbers = readLine.trim.split(' ').map(_.toInt)
  val (oneS, oneF) = calExpression(n, w, aNumbers, bNumbers, 1)
  val (zeroS, zeroF) = calExpression(n, w, aNumbers, bNumbers, 0)
  println(
    if (oneF < zeroF) oneS
    else zeroS
  )
  def calExpression(n: Int, w: Int, aNumbers: Array[Int], bNumbers: Array[Int], last: Int): (String, Long) = {
    val size = n + 2 * w + 3
    val start = size - 2
    val goal = size - 1
    val dinic = new Dinic(size)
    for (i ← 0 to w){
      if (i % 2 == 1){
        dinic.addEdge(start, i, Int.MaxValue)
      }else {
        dinic.addEdge(i, goal, Int.MaxValue)
      }
    }
    for (i ← w + 1 to w + n){
      dinic.addBiDirectionEdge(i, i - 1, aNumbers(i - w - 1))
      dinic.addBiDirectionEdge(i - w - 1, i + w, bNumbers(i - w - 1))
    }
    for (i ← w + n until start){
      if (i % 2 == last){
        dinic.addEdge(i, goal, Int.MaxValue)
      }else {
        dinic.addEdge(start, i, Int.MaxValue)
      }
    }
    val (flow, reachable) = dinic.reachableNodeFromSourceWithMaxFlow(start, goal)
    ((w + 1 to w + n).map{i ⇒
      if (reachable(i - 1) == reachable(i)) {
        '1'
      }else {
        '0'
      }
    }.mkString, flow)
  }
  object Dinic {
    case class Edge(to: Int, pair: Int, var capacity: Long)
  }
  class Dinic(val size: Int){
    private val edges: Array[ArrayBuffer[Edge]] = Array.tabulate(size){_ ⇒ ArrayBuffer()}
    def addEdge(from: Int, to: Int, capacity: Int): Unit = {
      edges(from).append(Edge(to, edges(to).length, capacity))
      edges(to).append(Edge(from, edges(from).length - 1, 0))
    }
    def addBiDirectionEdge(from: Int, to: Int, capacity: Int): Unit = {
      edges(from).append(Edge(to, edges(to).length, capacity))
      edges(to).append(Edge(from, edges(from).length - 1, capacity))
    }
    def reachableNodeFromSourceWithMaxFlow(source: Int, drain: Int): (Long, Array[Boolean]) = {
      val flow = calMaxFlow(source, drain)
      val isReachable = Array.tabulate(size){_ ⇒ false}
      def dfs(current: Int): Unit = {
        isReachable(current) = true
        for (Edge(to, _, c) ← edges(current) if c > 0 && !isReachable(to)){
          dfs(to)
        }
      }
      dfs(source)
      (flow, isReachable)
    }
    private[this] def calMaxFlow(source: Int, drain: Int): Long = {
      val depth = Array.tabulate(size){_ ⇒ -1}
      val searched = Array.tabulate(size){_ ⇒ 0}
      def bfs: Unit = {
        val queue = mutable.Queue[Int](source)
        depth.indices.foreach(i ⇒ depth(i) = -1)
        depth(source) = 0
        while (queue.nonEmpty){
          val current = queue.dequeue()
          if (current != drain) {
            for (next ← edges(current) if next.capacity > 0) {
              if (depth(next.to) == -1) {
                depth(next.to) = depth(current) + 1
                queue.enqueue(next.to)
              }
            }
          }
        }
      }
      def dfs(current: Int, bottleNeck: Long = Int.MaxValue): Long = {
        if (current == drain) bottleNeck
        else {
          var flow = 0L
          while (flow == 0 && searched(current) < edges(current).length) {
            val edge = edges(current)(searched(current))
            if (edge.capacity > 0 && depth(edge.to) > depth(current)) {
              flow = dfs(edge.to, math.min(bottleNeck, edge.capacity))
            }
            if (flow != 0) {
              edge.capacity -= flow
              edges(edge.to)(edge.pair).capacity += flow
            }else searched(current) += 1
          }
          flow
        }
      }
      var sumFlow = 0L
      bfs
      while (depth(drain) != -1){
        searched.indices.foreach(searched(_) = 0)
        var recent = dfs(source)
        while (recent != 0){
          sumFlow += recent
          recent = dfs(source)
        }
        bfs
      }
      sumFlow
    }
  }

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 54864