Go: package main

/*
グラフの表現 隣接行列による表現
*/

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

C++: /**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <cstdint>
#include <iostream>
#include <string>

constexpr int32_t kMaxVertexNumber = 110;

void CallGraph(std::istream &input_stream);

class Graph {
 public:
  Graph() noexcept;
  ~Graph() noexcept;

  void AddVertex(const int32_t vertex);
  void MapDirection(const int32_t vertex_number_from, const int32_t vertex_number_to);
  void Print() const noexcept;
  void Reset() noexcept;

 private:
  Graph(const Graph &obj) = delete;
  Graph &operator=(const Graph &obj) = delete;
  Graph(Graph &&obj) = delete;
  Graph &operator=(Graph &&obj) = delete;

  static bool IsInvalidVertexIndex(const int32_t index) noexcept;
  static bool IsInvalidVertexNumber(const int32_t vertex_number) noexcept;
  static int32_t ConvertFromVertexNumberToIndex(const int32_t node_number);
  static int32_t ConvertFromIndexToVertexNumber(const int32_t index);

 private:
  int32_t size_;
  int32_t adjacency_matrix_[kMaxVertexNumber - 1][kMaxVertexNumber - 1];
};

void CallGraph(std::istream &input_stream) {
  input_stream.tie(0);
  std::ios::sync_with_stdio(false);
  Graph *graph = new Graph();
  try {
    int32_t number_of_vertices;
    input_stream >> number_of_vertices;
    for (int32_t i = 0; i < number_of_vertices; ++i) {
      int32_t vertex_number, out_degree;
      input_stream >> vertex_number >> out_degree;
      graph->AddVertex(vertex_number);
      for (int32_t j = 0; j < out_degree; ++j) {
        int32_t tail_vertex;
        input_stream >> tail_vertex;
        graph->MapDirection(vertex_number, tail_vertex);
      }
    }
    graph->Print();
  } catch (...) {
    std::cerr << "ERROR: CallGraph()" << std::endl;
    throw;
  }
  delete graph;
}

// ****************************************************

Graph::Graph() noexcept : size_(0) {
  Reset();
}
Graph::~Graph() noexcept {}

void Graph::AddVertex(const int32_t vertex_number) {
  if (IsInvalidVertexNumber(vertex_number)) {
    std::cerr << "ERROR: AddVertex(): Invalid arg vertex_number = " << vertex_number << std::endl;
    throw 1;
  }
  size_ = (vertex_number > size_) ? vertex_number : size_;
}

void Graph::MapDirection(const int32_t vertex_number_from, const int32_t vertex_number_to) {
  if (IsInvalidVertexNumber(vertex_number_from)) {
    std::cerr << "ERROR: AddVertex(): Invalid arg vertex_number_from = " << vertex_number_from << std::endl;
    throw 1;
  } else if (IsInvalidVertexNumber(vertex_number_to)) {
    std::cerr << "ERROR: AddVertex(): Invalid arg vertex_number_to = " << vertex_number_to << std::endl;
    throw 1;
  } else {
    try {
      int32_t index_from = ConvertFromVertexNumberToIndex(vertex_number_from);
      int32_t index_to = ConvertFromVertexNumberToIndex(vertex_number_to);
      adjacency_matrix_[index_from][index_to] = 1;
    } catch (...) {
      std::cerr << "ERROR: MapDirection()" << std::endl;
      throw;
    }
  }
}

void Graph::Print() const noexcept {
  for (int32_t i = 0; i < size_; ++i) {
    for (int32_t j = 0; j < size_; ++j) {
      if (j != 0) {
        std::cout << " ";
      }
      std::cout << adjacency_matrix_[i][j];
      if (j == size_ - 1) {
        std::cout << std::endl;
      }
    }
  }
}

void Graph::Reset() noexcept {
  for (auto &row : adjacency_matrix_) {
    for (auto &element : row) {
      element = 0;
    }
  }
}

bool Graph::IsInvalidVertexNumber(const int32_t vertex_number) noexcept {
  return ((vertex_number < 1) || (vertex_number > kMaxVertexNumber));
}

bool Graph::IsInvalidVertexIndex(const int32_t index) noexcept {
  return ((index < 0) || (index >= kMaxVertexNumber));
}

int32_t Graph::ConvertFromVertexNumberToIndex(const int32_t vertex_number) {
  const int32_t index = vertex_number - 1;
  if (IsInvalidVertexIndex(index)) {
    std::cerr << "ERROR: ConvertFromVertexNumberToIndex(): Invalid vertex: index = " << index
              << ", vertex_number=" << vertex_number << std::endl;
    throw 1;
  }
  return index;
}

int32_t Graph::ConvertFromIndexToVertexNumber(const int32_t index) {
  if (IsInvalidVertexIndex(index)) {
    std::cerr << "ERROR: ConvertFromIndexToVertexNumber(): Invalid vertex: index = " << index << std::endl;
    throw 1;
  }
  return index + 1;
}

int main(int argc, char *argv[]) {
  try {
    CallGraph(std::cin);
  } catch (...) {
    std::cerr << "ERROR: main()" << std::endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int adj[101][101] = {};

int main()
{
    int n, u, k, v;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        while (k > 0)
        {
            cin >> v;
            adj[u][v] = 1;
            k--;
        }
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (j > 1)
                cout << " ";
            cout << adj[i][j];
        }
        cout << "\n";
    }
    return 0;
}