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<iostream>
#include<list>
using namespace std;

int main(void) {
	int n, u, k, s;
	cin >> n;
	bool table[102][102] = {};

	for (int i = 0;i <= n - 1;i++) {
		cin >> u >> k;
		for (int j = 0;j <= k - 1;j++) {
			cin >> s;
			table[u-1][s-1] = 1;
		}
	}

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

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int N;
int M[101][101] = {};

int main(void) {

    cin >> N;

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

        for (int k = 0; k < degree; ++k) {
            int adj;
            cin >> adj;

            M[v][adj] = 1;
        }

    }

    for (int i = 1; i <= N; ++i) {
        for (int k = 1; k <= N; ++k) {
            cout << M[i][k];
            if (k != N) cout << " ";
        }
        cout << endl;
    }

    return 0;
}

C++: #include<stdio.h>
int main(){
  int a,b,d,j,i,c;
  int A[100][100]={};
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d%d",&b,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      A[b-1][c-1]=1;
    }
  }
  for(i=0;i<a;i++){
    for(j=0;j<a;j++){
      if(j==a-1)printf("%d",A[i][j]);
      else printf("%d ",A[i][j]);
    }
    printf("\n");
  }
}

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

int main() {

    int n , u , k , s;
    cin>> n ;
    vector<vector<int> > v(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int r=0;r<k;r++){
        cin >> s;
        v[u-1][s-1] = 1;

    }
    }
    for(int i=0;i<n;i++){

        for(int r=0;r<n;r++){
            cout << v[i][r] ; 
            if(r==n-1){}
            else {cout << " " ;}
        }
        cout << endl;
    }
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
  int M[N][N];  // 0 オリジンの配列
  int n, u, k, v;

  cin >> n;

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

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

  return 0;
}

C++: #include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using NumNode = short;
using List = std::vector<NumNode>;
struct Node {
    NumNode idx;
    NumNode value;
    List list;
};
using Nodes = std::vector<Node>;
using Edge = bool;
using Row = std::vector<Edge>;
using Array = std::vector<Row>;

Nodes input_nodes(NumNode n_node);
List make_val2idx(Nodes nodes);
Array solve(Nodes nodes);
void print_graph_array(Array array);

int main() {
    NumNode n;
    std::cin >> n;
    Nodes nodes = input_nodes(n);
    const Array array = solve(nodes);
    print_graph_array(array);
}

Nodes input_nodes(NumNode n_node) {
    Nodes nodes{};
    for (NumNode i = 0; i < n_node; ++i) {
        NumNode u, k;
        std::cin >> u >> k;

        Node node{};
        node.idx = i;
        node.value = u;

        List list{};
        for (NumNode j = 0; j < k; ++j) {
            NumNode v;
            std::cin >> v;
            list.push_back(v);
        }
        node.list = list;
        nodes.push_back(node);
    }
    return nodes;
}

Array solve(Nodes nodes) {
    Array array{};
    List val2idx = make_val2idx(nodes);
    for (Node node : nodes) {
        Row row{};
        row.resize(nodes.size());
        for (NumNode node_dst : node.list) {
            const NumNode node_dst_idx = val2idx.at(node_dst);
            row.at(node_dst_idx) = true;
        }
        array.push_back(row);
    }
    return array;
}

List make_val2idx(Nodes nodes) {
    List val2idx{};
    NumNode value_max = std::numeric_limits<NumNode>::max();
    val2idx.resize(value_max);
    for (Node node : nodes) val2idx[node.value] = node.idx;
    return val2idx;
}

void print_graph_array(Array array) {
    for (Row row : array) {
        for (auto iter_edge = row.begin(); iter_edge != row.end();
             ++iter_edge) {
            std::cout << *iter_edge;
            if (iter_edge != end(row) - 1) std::cout << ' ';
        }
        std::cout << std::endl;
    }
}

C++: #include <stdio.h>

int main(){
    int Map[101][101];
    int N, u, k, temp;
    scanf("%d\n",&N);
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++)
            Map[ix][jx] = 0;
    for (int ix = 0; ix < N; ix++){
        scanf("%d %d",&u,&k);
        for (int kx = 0; kx < k; kx++){
            scanf("%d",&temp);
            Map[u-1][temp-1] = 1;
        }
    }
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++){
            if (jx == N-1) printf("%d\n",Map[ix][jx]);
            else printf("%d ",Map[ix][jx]);
        }
    return 0;
}

C++: #include <iostream>
#include <set>
using namespace std;
static const int N = 100;

int n;

set<int> G[100];

int main(int argc, char const *argv[])
{
    int k, u, g;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> k >> u;
        for (int j = 0; j < u; j++) {
            cin >> g;
            G[i].insert(g);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (!G[i].empty()) {
                cout << ((j==0) ? "" : " ");
                cout << ((G[i].find(j+1) != G[i].end()) ? "1" : "0");
            } else {
                cout << ((j==0) ? "" : " ");
                cout << "0";
            }
        }
        cout << endl;
    }

    return 0;
}