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 <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) {
                    if(j!=n){
                        cout << 1 <<" "; hantei=1;
                    }else{
                        cout << 1 ;
                    }    
                }
            }
            if(hantei==0){ 
                if(j!=n){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            };
        }cout << endl;
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	int graph[125][125];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			graph[i][j] = 0;
		}
	}
	for(int i=1;i<=n;i++){
		int num;
		int k;
		int tmp;
		cin >> num >> k;
		if(k !=0){
			for(int j=0;j<k;j++){
				cin >> tmp;
				graph[num][tmp] = 1;
			}
		}
	}
	for(int i = 1; i<=n;i++){
		for(int j= 1;j<=n;j++){
			if(j != n)cout << graph[i][j] <<" ";
			if(j == n) cout << graph[i][j] <<  endl;
		}
	}
}

C++: #include <iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int mat[n][n];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            mat[i][j] = 0;
        }
    }
    for(int i = 0; i < n; ++i){
        int id;
        cin >> id;
        int k;
        cin >> k;
        int v;
        for(int j = 0; j < k; ++j){
            cin >> v;
            mat[id-1][v-1] = 1;
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(j == 0){
                cout << mat[i][j];
            } else {
                cout << ' ' << mat[i][j];
            }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <istream>
 
#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

 int main(int argc, char **argv){
	int n = 0;
	int u = 0;
	int v = 0;
	int k = 0;
	std::vector<int> A;
 
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
 
 
#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	A.resize(n * n, 0);

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> u >> k;
#else
		std::cin >> u >> k;
#endif
		for(int j = 0; j < k; j++){
#if INPUT_FROM_FILE
			ifs >> v;
#else
			std::cin >> v;
#endif
			A[(u - 1) * n + v - 1] = 1;
		}
	}
 
	for(int r = 0; r < n; r++){
		int offset = r * n;
		std::cout << A[offset];
		for(int c = 1; c < n; c++){
			std::cout << " " << A[offset + c];
		}
		std::cout << std::endl;
	}
    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n,a,b,c;
  int adj[100][100]={0};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<b;j++){
      cin>>c;
      adj[i][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      //if(j)cout<<' ';
      cout<<adj[i][j]<<' ';
    }
    cout<<endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define maxn 10005
int n,u,k;
int g[maxn][maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int v;
        scanf("%d%d",&u,&k);
        for(int j=1;j<=k;j++)
        {
            scanf("%d",&v);
            g[u][v]=1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            printf("%d ",g[i][j]);
        }
        printf("%d\n",g[i][n]);
    }

    return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<int>> am(n, std::vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    int k, u;
    std::cin >> u >> k;
    for (int j = 0; j < k; ++j) {
      int v;
      std::cin >> v;
      am[u-1][v-1] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      std::cout << am[i][j] << (j == n-1 ? "\n" : " ");
    }
  }
}