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 <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> g(n, vector<int>(n, 0));
    int u, k;
    REP(i, n) {
        cin >> u >> k;
        u--;
        int v;
        REP(j, k) {
            cin >> v;
            v--;
            g[u][v] = 1;
        }
    }
    REP(i, n) {
        REP(j, n) {
            cout << g[i][j] << (j == n - 1 ? endl : ' ');
        }
    }
}

C++: // ALDS1_11_A.cpp
// Graph I - Graph

#include <iostream>
#include <vector>
using namespace std;

void print(vector<vector<int>> &A, int n)
{
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
}

int main()
{
    int n;
    cin >> n;
    int id;
    int num;
    vector<vector<int>> A(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> id >> num;
        if (num == 0) continue;
        else {
            int tmp;
            for (int j = 0; j < num; j++) {
                cin >> tmp;
                A[id - 1][tmp - 1] = 1;
            }
        }
    }

    print(A, n);

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
// 邻接表转化为邻接矩阵
int mat[105][105]; 
int main(){
//	freopen("a.txt","r",stdin);
	memset(mat,0,sizeof(mat));
	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;
//			mat[u-1][v-1]=1;
			mat[u][v]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n-1;j++){
			cout<<mat[i][j]<<' ';
		}cout<<mat[i][n]<<endl;
	}
	return 0;
}

C++: // 最長共通部分列 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100
// 無効な値の定義
const int INV = -1;

int main(void)
{
    int n, u, num, v_num;
    int ary_graph[MAX_N + 1][MAX_N + 1];

    for(int i = 0; i < MAX_N + 1; i++)
    {
        for(int j = 0; j < MAX_N + 1; j++)
        {
            // 配列の初期化
            ary_graph[i][j] = 0;
        }
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> u;
        cin >> num;

        for(int j = 0; j < num; j++)
        {
            // 隣接点を記憶する
            cin >> v_num;
            // 0オリジンに変更する
            ary_graph[u - 1][v_num - 1] = 1;
        }
    }

    // 結果の表示をする
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if( j > 0 )
            {
                cout << " ";
            }

            cout << ary_graph[i][j];
        }

        cout << endl;
    }

    return 0;
}

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

int main()
{
	int i,j,n,u,k;
	int v[100][100];
	cin >> n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			v[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		cin >> u;
		for(j=0;j<u;j++){
			cin >> k;
			v[i][k-1]=1;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cout << v[i][j] << " ";
		}
		cout<<endl;
	}
}

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

int main(){
	int n,m,l,i,j,p;
	cin >> n;
	int f[100][100];
	for ( i = 0; i < n; i++){
		cin >> m;
		cin >> p;
		for ( j = 0; j < p; j++){
			cin >> l;
			f[m-1][l-1] = 1;
		}
	}
	for ( i = 0; i < n; i++){
		for ( j = 0; j < n-1; j++){
			cout << f[i][j] << " ";
		}
		cout << f[i][n-1] << endl;
	}
}

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

int main() {
    int n; cin >> n;
    int u, k;
    int M[110][110] = {0};

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

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

C++: #include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int t[111][111];
 
  memset(t,0,sizeof(t));
  int n;
  cin >> n;
 
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    for(int j = 0; j < b; j++){
      int c;
      cin >> c;
      t[a][c] = 1;
    }
  }
 
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(j != n)
      cout << t[i][j] << " ";
      else
    cout << t[i][j];
 
    }
    cout << endl;
  }
 
 
}