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++: #include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
    // 頂点数
    int cnt_vertex(0);

    cin >> cnt_vertex;
    vector<vector<int>> vecGraph(cnt_vertex,vector<int>(cnt_vertex,0));

    int num_vertex(0), cnt_exit_vertex(0);

    for (int i = 0; i < cnt_vertex; i++)
    {
        cin >> num_vertex >> cnt_exit_vertex;
        int num_next_vertex(0);
        for (int j = 0; j < cnt_exit_vertex; j++)
        {
            cin >> num_next_vertex;
            // cout << endl;
            // cout << cnt_vertex << endl;
            vecGraph[i][num_next_vertex-1] = 1;
        }
    }

    for (int i = 0; i < cnt_vertex; i++)
    {
        for (int j = 0; j < cnt_vertex; j++)
        {
            if(j == cnt_vertex-1) {
                cout << vecGraph[i][j] << "\n";
            } else {
                cout << vecGraph[i][j] << " ";
            }
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
 int dp[200][200] = {0};

 void pgraph(int n){
      for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout << dp[i][j];
      if(j != n)cout << " ";
    }
    cout << endl;
  }

 }
int main(){
  int n,u,k;
  int ad;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      dp[u][ad] = 1;
    }
  }
  pgraph(n);
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin>>N;
    vector<vector<int>> G(N,vector<int>(N));
    for(int i=0;i<N;i++){
        int u,k; cin>>u>>k;
        u--;
        while(k--){
            int v; cin>>v;
            v--;
            G[u][v]=1;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cout<<G[i][j]<<(j==N-1? '\n':' ');
        }
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n, k, u, v, i, j;
    cin >> n;
    int m[n+1][n+1];
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++) m[i][j] = 0;
    }
    for(i = 1; i <= n; i++){
        cin >> u >> k;
        for(j = 1; j <= k; j++){
            cin >> v;
            m[u][v] = 1;
        }
    }
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            if(j == n) cout << m[i][j] << endl;
            else cout << m[i][j] << " ";
        }
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

static const int N = 100;

int main()
{
    int M[N][N];    // 0オリジンの隣接行列
    int n, u, k, v;
    int i, j;

    cin >> n;

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) M[i][j] = 0;
    }

    for (i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;        // 0オリジンへ変換
        for (j = 0; j < k; j++) {
            cin >> v;
            v--;    // 0オリジンへ変換
            M[u][v] = 1;    // u と v の間に辺を張る
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include <vector>
#include <iostream>

using namespace std;

int N;

int main()
{
	cin >> N;

	vector<vector<bool> > M(N, vector<bool>(N));

	int u, k, v;

	for (int i = 0; i < N; i++)
	{
		cin >> u >> k;

		for (int i = 0; i < k; i++)
		{
			cin >> v;

			M[u - 1][v - 1] = true;
		}
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cout << M[i][j];

			if (j == N - 1)
			{
				cout << ' ';
			}
		}

		cout << endl;
	}

	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<vector<int>> G(n, vector<int>(n, 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;
            G[u - 1][v - 1] = 1;
        }
    }

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

    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <limits.h>
using namespace std;

int a[101][101];
int main(){
	int n; scanf("%d",&n);
	for (int i = 1; i <= n; ++i){
		int u, k; scanf("%d %d",&u,&k);
		int tmp;
		while(k--){
			scanf("%d",&tmp);
			a[u][tmp] = 1;
		}
	}
	for (int i = 1; i <= n; ++i){
		for (int j = 1; j <= n; ++j){
			if (j != 1) cout << ' ';
			cout << a[i][j];
		}
		cout << '\n';
	}
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                if(vec[i][k]==j) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }cout << endl;
}