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>

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define ll long long
#define bpm %1000000007

using namespace std;

ll powAns(ll,ll);

int main(){
    int n,u,k;
    int a;
    cin>>n;
    int vec[n][n];

    rep(i,n)rep(j,n)vec[i][j]=0;

    rep(i,n){
        cin>>u>>k;
        rep(j,k){
            cin>>a;
            vec[u-1][a-1]=1;
        }
    }
    rep(i,n){
        rep(j,n-1)cout<<vec[i][j]<<" ";
        cout<<vec[i][n-1]<<endl;
    }
}

ll powAns(ll m ,ll n){
    ll res=1;
    while(n>0){
        if(n & 1)res = res*m bpm;

        m=m*m bpm;
        n>>=1;
    }

    return res;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#define MAX 110

using namespace std;

static const int N = 110;

int main(){
    int n;//頂点数
    cin >> n;

    int Adj[MAX];
    int M[N][N];
    
    int u;
    int k;
    int v;
    
    for(int i=1; i<=n; i++){
        M[i][i] = 0;
    }
    
    
    for(int j=1; j<=n; j++){
        cin >> u >>k;
        for(int a=1; a<=k; a++){
            cin >> v;
            Adj[v] = 1;
            
            if(Adj[v] != 0){
            M[u][v] = 1;
            }
        }
         
        
    }
    
    for(int j=1;j<=n; j++){
        for(int i=1; i<=n; i++){
            if(i != 1){
                cout << " ";
            }
            cout << M[j][i];
        }
        
        cout << endl;
        
    
    }
    
    
    
    return 0;
    
}

C++: #include <iostream>
//给一个图的邻接表，输出其邻接矩阵

using namespace std;

static const int N=100;

int main(){
    int M[N][N];

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

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

}

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

int main() {
  int n, k, v, u;
  cin >> n;
  vector<vector<int>> ADJ(n, vector<int>(n, 0));
  for (size_t i = 0; i < n; i++) {
    cin >> u >> k;
    for (size_t j = 0; j < k; j++) {
      cin >> v;
      ADJ[u - 1][v - 1] = 1;
    }
  }

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

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

int main(){
    int n, val, link, linknum;
    cin >> n;
    int Graphlinked[n][n];
    for(int i=0; i<n; i++){
        for(int k=0; k<n; k++){
            Graphlinked[i][k] = 0;
        }
        cin >> val >> linknum;
        for(int j=0; j<linknum; j++){
            cin >> link;
            Graphlinked[i][link - 1] = 1;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j) cout << " ";
            cout << Graphlinked[i][j];
        }
        cout << endl;
    }
}

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

int main(){
	int n,a,b=-1,j=0;
	char input[110];
	string scan;
	int line[110]={0};
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int k=1;k<=n;k++)line[k]=0;
		strcpy(input,"");		
		b=-1; j=0;
		while(1){
			b--;
			if(b==0)break;
			cin>>a;
			if(b>0)line[a]=1;
			
			if(j==1)b=a+1;
			j++;
		}
		for(int k=1;k<=n;k++)cout<<line[k]<<" ";
		cout<<endl;
	}
	
	return 0;
}

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

const static int N = 100;

int main() {
  int n, G[N][N];
  int v, m, k;
  
  cin >> n;

  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) G[i][j] = 0;
  }

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

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

  return 0;    
}