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 <queue>
using namespace std;

typedef struct node{
    int vertexCode;
    node* next;
}* nodeptr;

class chainTable {
private:
    // nothing :P
public:
    nodeptr head, tail;

    chainTable() : head(NULL), tail(NULL) {}

    void push(int newVC) {  //  VC = Vertex Code
        nodeptr tmp = new node();
        tmp->vertexCode = newVC;
        tmp->next = NULL;

        if (this->head == NULL) {
            this->head = this->tail = tmp;
        } else {
            this->tail = this->tail->next = tmp;
        }
    }

    bool canGoTo(int target) {
        nodeptr tmp = this->head;
        while (tmp != NULL) {
            if (tmp->vertexCode == target) return true;
            else tmp = tmp->next;
        }

        return false;
    }

//    void travel(int target) {
//        nodeptr tmp = this->head;
//        while (tmp != NULL) {
//            if (tmp->vertexCode == target) return true;
//            else cout << tmp->vertexCode;
//        }
//
//        return false;
//    }
};

int main() {
   // freopen("in.txt", "r", stdin);

    int n, u, k, v;
    cin >> n;

    vector<chainTable> aList(n + 1);  // aList = adjacency list

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            aList[u].push(v);
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (aList[i].canGoTo(j)) {
                cout << "1";
            } else {
                cout << "0";
            }
            if (j != n) cout << " ";
        }
        cout << endl;
    }
//
//    cout << "--------------" << endl;
//    for (int i = 0; i < n; ++i) {
//        aList[i].travel();
//    }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int martix[105][105];

int main()
{
	int n, id, d,v;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> id >> d;
		while (d--)
		{
			cin >> v;
			martix[id][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (j ==1)	cout << martix[i][j];
			else cout << ' ' << martix[i][j];
		}
		putchar('\n');
	}
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<vector<int>> vec(n, vector<int>(n, 0));

    for (int i = 0; i < n; i++)
    {
        int u, k, tmp; cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> tmp;
            vec.at(i).at(tmp-1)=1;
        }
        
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << vec.at(i).at(j) ;
            if(j!=n-1) cout << " ";
        }
        if(i!=n-1)  cout << endl;
    }
    
}
//g++ -o a.exe a.cpp

C++: #include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<stdlib.h>
#include<queue>
#include<vector>
#include<list>
using namespace std;
int mp[111][111];
int main ()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<111;i++)
        for(int j=0;j<111;j++)
            mp[i][j]=0;
    for(int i=1;i<=n;i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        for(int j=1;j<=v;j++)
        {
            int w;
            scanf("%d",&w);
            mp[u][w]=1;
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    {
        if(j==n)
            printf("%d\n",mp[i][j]);
        else
            printf("%d ",mp[i][j]);
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int G[102][102];
int main(){
	int n;
	scanf("%d",&n); 
	for(int i=1;i<=n;i++){
		int k,v1,v2;scanf("%d%d",&v1,&k);
		for(int j=1;j<=k;j++){
			scanf("%d",&v2);G[v1][v2]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j!=n)
			printf("%d ",G[i][j]);
			else printf("%d",G[i][j]);
		}printf("\n");
	}
	return 0;
}

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



int main(void)
{
	int N, v, k, x;
	cin >> N;
	
	vector<vector<int>> G(N + 1, vector<int>(N + 1, 0));
	for (int i = 0; i < N; i++)
	{
		cin >> v >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> x;
			G[v][x] = 1;
		}
	}

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

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        int u, k;
        cin >> u >> k;
        int *ary = new int[n+1];
        for(int j=1; j<=n; j++) {
            ary[j] = 0;
        }
        for(int j=0; j<k; j++) {
            int v;
            cin >> v;
            ary[v] = 1;
        }
        for(int j=1; j<=n; j++) {
            if(j != 1) cout << " ";
            cout << ary[j];
        }
        cout << "\n";
        delete[] ary;
    }
}

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