
n = gets.to_i
adj=[]
n.times do |i|
  adj[i] = gets.split.map &:to_i
end

def adj.adjacency_list_to_adjacency_matrices
  matrices = Array.new(self.length) {Array.new(self.length,0)}
  self.each do |adj|
    u, k, *v = adj[0], adj[1], adj[2..-1]
    v.flatten.each do |v|
      matrices[u-1][v-1] = 1
    end
  end
  matrices
end

result =  adj.adjacency_list_to_adjacency_matrices
result.each{|r| puts r.join " "}

