Go: package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	graph := make([][]int, N)
	for i := range graph {
		graph[i] = make([]int, N)
		var u, k int
		fmt.Scan(&u, &k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			v--
			graph[i][v] = 1
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if j > 0 {
				fmt.Print(" ")
			}
			fmt.Print(graph[i][j])
		}
		fmt.Println()
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int V;
	cin >> V;
	vector <vector <bool>> adj(V, vector <bool> (V, 0));
	rep(V, i) {
		int u, k;
		cin >> u >> k;
		u--;
		rep(k, j) {
			int n;
			cin >> n;
			n--;
			adj[u][n] = 1;
		}
	}
	rep(V, i) rep(V, j) {
		cout << adj[i][j] << ' ';
		if (j == V-1) cout << endl;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}

C++: //
// Created by 李青坪 on 2018/10/31.
//

#include <cstdio>
#include <algorithm>

#define MAXN 101
using namespace std;

int graph[MAXN][MAXN];

void init(){
    for (auto &i : graph) {
        fill(i, i +MAXN, 0);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    init();
    int v, dgr;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v, &dgr);
        int node;
        for (int j = 0; j < dgr; ++j) {
            scanf("%d", &node);
            graph[v][node] = 1;
        }
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            if (i-1) printf(" ");
            printf("%d", graph[k][i]);
        }
        printf("\n");
    }
}
/*
4
1 2 2 4
2 1 4
3 0
4 1 3

 */

C++: #include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

 int n;
 cin >> n;

 int m[n+1][n+1];
 for(int i = 0;i <= n;i++) {
   for(int j = 0;j <= n;j++) {
     m[i][j] = 0;
   }
 }

 for(int i = 0;i < n;i++) {
   int u,k;
   cin >> u >> k;
   for(int j = 0;j < k;j++) {
     int v;
     cin >> v;
     m[u][v] = 1;
   } 
 }

 for(int i = 1;i <= n;i++) {
   for(int j = 1;j <= n;j++) {
     if(j>1) cout << " ";
     cout << m[i][j];
   }
   cout << endl;
 }


  
}

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