Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

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;
}