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>
using namespace std;
int main(){
        int N;
        cin >> N;
        int lt[200][200]={0};
        for( int i=0 ; i<N ; i++ ){
                int x,y,n;
                cin >> x >> n;
                for(int l=0 ; l<n ; l++ ){
                        cin >> y;
                        lt[x-1][y-1]=1;
                }
        }
        for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                        cout<<lt[i][j];
                        if(j!=N-1)cout<<" ";
                }
                cout<<endl;
        }
        return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,k,a,u,V[200][200];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>k;
        for(int j=1;j<=k;j++){
            cin>>u;
            V[a][u]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j==1) cout<<V[i][1];
            else cout<<" "<<V[i][j];
        }
        cout<<endl;
    }
}

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

int main () {
    int n;
    cin >> n;
    int M[n][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++){
        int id, k;
        cin >> id >> k;
        for (int j = 0; j < k; j++){
            int tmp;
            cin >> tmp;
            M[i][tmp-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;
            }
            
        }
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

static const int N = 100;

int main(){
  int G[N][N];
  int u, v, k, n;

  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 >> u >> k;
     u--;
     for(int j = 0; j < k; j++){
       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;
   }

   return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int> > graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(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++){
        scanf("%d",&u);
        scanf("%d",&k);
        int value;
        for(int j=0;j<k;j++){
            scanf("%d",&value);
            graph[u-1][value-1]=1;
        }
    }

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

    return 0;
}

C++: //16D8104001K 田中誠人 makoto0106 c++
#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
  std::vector<int>num;
  int n,k,tmp,x,size;

  std::cin>>n;
  
  for(int i=0;i<n;i++){
    std::cin>>tmp>>k;
    num.push_back(k);
    for(int j=0;j<k;j++){
      std::cin>>tmp;
      num.push_back(tmp);
      //std::cout<<tmp<<" ";
    }
  }
  size=num.size();
  /*
  for(int i=0;i<size;i++){
    std::cout<<num[i]<<" ";
  }
  */
  x=0;
  std::cout<<"\n";
  while(x<size){
    if(num[x]==0){
      for(int i=0;i<n;i++){
	std::cout<<"0 ";
      }
      x++;
    }else{
      x++;
      for(int i=0;i<n;i++){
      
	if(i+1==num[x]){
	  std::cout<<"1 ";
	  x++;
	}else{
	  std::cout<<"0 ";
	}
      }
    }
    std::cout<<"\n";
  }
  

  std::cout<<"\n";

  
  return 0;
}
/*実行結果
4
1 2 2 4
2 1 4
3 0
4 1 3

0 1 0 1 
0 0 0 1 
0 0 0 0 
0 0 1 0 

*/

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

int main() {
	int n,graph[100][100];
	cin >> n;

	for (int i = 0; i < n; i++) {
		int vertex,jisu;
		cin >> vertex>>jisu;
		for (int j = 0; j < jisu; j++) {
			int to;
			cin >> to;
			graph[vertex-1][to-1] = 1;
		}
	}

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

	return 0;
}

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

int main() {
	int n, u, k, v;
	cin >> n;
	vector<vector<bool>> am(n, vector<bool>(n));
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v;
			am[u - 1][v - 1] = true;
		}
	}
	for (vector<bool>& i : am) {
		cout << i[0];
		for (int j = 1; j < n; ++j) cout << ' ' << i[j];
		cout << endl;
	}
}

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

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

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