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 <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
using Matrix = vector<vector<int>>;
Matrix d;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    d = Matrix(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        int u,k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; ++j) {
            int v;
            cin >> v;
            d[u][v-1] = 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(j!=n-1)cout << d[i][j] << " ";
            else cout << d[i][j] << endl;
        }

    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

void printarray(int n, int a[])
{
    for (int i = 1; i < n + 1; i++)
    {
        cout << a[i];
        if (i != n)
            cout << " ";
    }
    cout << endl;
}

int cycleanalysis(int n, int a[])
{
    int pos, ret, next;
    pos = 0, ret = 0;
    for (int i = 1; i < n + 1; i++)
    {
        pos = i;
        while (a[pos] != pos)
        {
            ret += (a[pos] + a[a[pos]]);
            next = a[pos];
            swap(a[pos], a[a[pos]]);
            pos = next;
        }
    }

    return ret;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

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

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int point_number;
	cin >> point_number;
	vector<vector<int>>v(point_number);
	for (int i = 0;i < point_number;i++) {
		int point;
		cin >> point;
		v[i].push_back(point);
		int rinsetu;
		cin >> rinsetu;
		v[i].push_back(rinsetu);
		for (int j = 0;j < rinsetu;j++) {
			int tunagari;
			cin >> tunagari;
			v[i].push_back(tunagari);
	


		}

	
	
	
}
	vector<vector<int>>ans(point_number,vector<int>(point_number));
	for(int i = 0;i < point_number;i++){
		for (int j = 0;j < v[i][1];j++) {
			ans[v[i][0]-1][v[i][j + 2]-1] = 1;
		}


	}
	for (int i=0;i < point_number;i++) {
		for (int j=0;j < point_number;j++) {
			if (j == 0) {
				cout << ans[i][j];
			}
			else {
				cout << " " << ans[i][j];
			}
		}
		cout << endl;
	}
	
}

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

int main()
{
	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--;
		for( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			v--;
			g[u][v] = 1;
		}
	}

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

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

int main(){
    int n; cin >> n;

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 101;
int M[MAX][MAX];

int main()
{
    int n, m, s, v;
    cin >> n;
    for (int i = 0; i <= MAX; ++i)
    {
        for (int j = 0; j <= MAX; ++j)
        {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i != n; ++i)
    {
        cin >> m >> s;
        while (s--)
        {
            cin >> v;
            M[m][v] = 1;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            cout << M[i][j];
            if (j != n)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>> n;
  vector<vector<int> > v;
  v = vector<vector<int> >(n, vector<int>(n,0));
  for(int i=0; i<n; ++i){
    int tmp;
    cin >> tmp;
    cin >> tmp;
    for ( int j=0; j<tmp; ++j){
      int to;
      cin >> to;
      v[i][to-1] = 1;
    }
  }
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      cout << v[i][j];
      if( j != n-1) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}