Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <cstring>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int A[110][110];

int main(){
    int n,m,a,b;
    cin>>n;
    LP(i,n){
        cin>>a>>m;
        LP(j,m){
            cin>>b;
            A[a-1][b-1]=1;
        }
    }
    LP(i,n){
        LP(j,n){
            if(j==n-1) cout<<A[i][j]<<endl;
            else cout<<A[i][j]<<" ";
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#define Lens 100
using namespace std;
int N;
int A[Lens][Lens];

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int k, n;
		cin >> k >> n;
		for (int i = 0; i < n; i++)
		{
			int j;
			cin >> j;
			A[k][j] = 1;
		}
	}
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			if (j > 1)
				cout << ' ';
			cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
    int n;
    int from_num, num; 
    std::cin >> n;
    std::vector<std::vector<int>> vec(n, std::vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        std::cin >> from_num;
        std::cin >> num;
        int node_num;
        for (int p = 0; p < num; p++) {
            std::cin >> node_num;
            vec[from_num-1][node_num-1] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int p = 0; p < n; p++) {
            std::cout << vec[i][p];
            if (p == n - 1) {
                std::cout << std::endl;
            }
            else {
                std::cout << " ";
            }
        }
    }
}

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

#define check cout<<"-------"<<endl
#define debug(x) cout<<x<<endl;

#define N 101

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a[N][N] = {};
    int n;
    cin>>n;
    
    int u, k, v;
    for(int i = 0; i < n; i++) {
        cin>>u>>k;
        
        for(int j = 0; j < k; j++) {
            cin>>v;
            a[u][v] = 1;
        }
    }
    
    int i, j;
    for(i = 1; i <= n; i++) {
        for(j = 1; j < n; j++) {
            cout<<a[i][j]<<' ';
        }
        cout<<a[i][j]<<endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int maxn=100+10;
int n;
int g[maxn][maxn];
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int no,cnt,dd;
    memset(g,0,sizeof(g));
   for(int i=0;i<n;i++)
    {
        scanf("%d%d",&no,&cnt);
        for(int j=0;j<cnt;j++)
        {
            scanf("%d",&dd);
            g[no-1][dd-1]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j) printf(" ");
            printf("%d",g[i][j]);
        }
        printf("\n");
    }

    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> mat(n,vector<ll>(n,0));
    for(ll i=0;i<n;i++) {
        ll u,k;
        cin>>u>>k;
        for(ll j=0;j<k;j++) {
            ll tmp;
            cin>>tmp;
            mat[u-1][tmp-1] = 1;
        }
    }
    for(ll i=0;i<n;i++) {
        for(ll j=0;j<n;j++) {
            if(j<n)cout << mat[i][j] << " ";
            else cout << mat[i][j];
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
#include <cstdlib>
using namespace std;
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}

int main() {
	vector<vector<int> > M(100,vector<int>(100,0));
	int N, U, K, V;
	cin >> N;
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			M.at(i).at(j)=0;
		}
	}
	for (i = 0; i < N; i++) {
		cin >> U >> K;
		U--;
		for (j = 0; j < K; j++) {
			cin >> V;
			V--;
			M.at(U).at(V) = 1;
		}
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (j) {
				cout << " ";
			}
			cout << M.at(i).at(j);
		}
		cout << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
const int MAX = 1000000000;

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    for(int i = 0; i < N; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for(int i = 0; i < k; i++) {
            int v;
            cin >> v;
            v--;
            G[u].push_back(v);
        }
    }
    for(int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int ans = 0;
            for (auto v : G[i]) {
                if(j==v){
                    ans = 1;
                }
            }
            cout << ans;
            if(j<N-1)cout<<' ';
        }
        cout << endl;
    }
}