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<stdio.h>
using namespace std;
#define N 100

int main(){
    int graph[N][N];
    int n;
    int c,l; 
    int arc; 
    cin >> n;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            graph[i][j] = 0;
    
   for(int i=0;i<n;i++){
        cin >> c;
        cin >> arc;
        for(int j=0;j<arc;j++){
            cin>> l;
            graph[c-1][l-1]=1;
        }
    }

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

C++: #include "stdio.h"
#include<iostream>

using namespace std;

int main(void){

  int N;
  scanf("%d", &N);

  int node_num, dimention, adjacency_node_num;  
  
  int** matrix = new int* [N];
  for(int i=0;i<N;i++){
    matrix[i] = new int [N];
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      matrix[i][j] = 0;
    }
  }

  for(int i=0;i<N;i++){
    cin >> node_num >> dimention;

    for(int i=0;i<dimention;i++){
      cin >> adjacency_node_num;
      matrix[node_num-1][adjacency_node_num-1] = 1;
    } 
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(j != 0){
        printf(" ");
      }
      printf("%d", matrix[i][j]);
    }
    printf("\n");
  }

  for(int i=0;i<N;i++){
    delete [] matrix[i];
  }

  delete [] matrix;  

  return 0;
}

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

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

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

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

C++: #include <iostream>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    int graph[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            graph[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int a,temp;
        cin>>a>>temp;
        for(int j=0;j<temp;j++)
        {
            int k;
            cin>>k;
            graph[i][k]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int j;
        for(j=1;j<n;j++)
        {
            cout<<graph[i][j]<<' ';
        }
        cout<<graph[i][j]<<endl;
    }
    return 0;
}

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

int G[110][110] ={0};

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

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

C++: #include <iostream>
#include "string.h"
using namespace std;
int m[107][107];
int main(int argc, char *argv[]) {
	int n,u,k,v;
	cin>>n;
	memset(m, 0, sizeof(m));
	for(int i=1;i<=n;i++)
	{
		cin>>u>>k;
		for(int j=1;j<=k;j++)
		{
			cin>>v;
			m[u][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 <iostream>
#include <string>
#include <vector>


using namespace std;


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


  vector< vector<int> > a;
  for(int i=0;i<n;i++){
    int u;
    int k;
    cin >> u >> k;
    vector<int> tmpa;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      tmpa.push_back(tmp);
    }

    a.push_back(tmpa);
  }

  
  
  int a2[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a2[i][j]=0;
    }
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<(int)a[i].size();j++){
      a2[i][a[i][j]-1] = 1;
    }
  }

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