case class Adj(u: Int, k: Int, vs: Seq[Int]) {
  def convertToMat(n: Int): Seq[Int] = gen(1, n, vs, Nil)

  def print(n: Int): Unit = println(convertToMat(n).mkString(" "))

  private def gen(i: Int, n: Int, vs: Seq[Int], line: Seq[Int]): Seq[Int] = {
    if (i > n) {
      line
    } else if(vs.headOption.contains(i)) {
      gen(i + 1, n, vs.tail, line :+ 1)
    } else {
      gen(i + 1, n, vs, line :+ 0)
    }
  }
}

object Adj {
  def apply(line: String): Adj = {
    val input = line.split(' ')
    Adj(input(0).toInt, input(1).toInt, input.drop(2).map(_.toInt))
  }
}

object Main extends App {
  private val lines = io.Source.stdin.getLines.toSeq
  private val n = lines.head.toInt

  lines.tail.foreach(Adj(_).print(n))
}