Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			if j == n-1 {
				fmt.Printf("%d\n", Adj[i][j])
				continue
			}
			fmt.Printf("%d ", Adj[i][j])
		}
	}
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main(){
    int M[N][N]; //0オリジンの隣接行列
    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--; //0オリジンへ変換
        for(int j=0; j<k; j++){
            cin >> v;
            v--; //0オリジンへ変換
            M[u][v] = 1; //uとvの間に辺を張る
        }
    }

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

    return 0;
}

C++: #include<stdio.h>
#define N 100

main(){
int M[N][N];
int n,u,k,v;
int i,j;

scanf("%d",&n);

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

for(i=0;i<n;i++){
scanf("%d%d",&u,&k);
u--;
for(j=0;j<k;j++){
scanf("%d",&v);
v--;
M[u][v]=1;
}
}

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

return 0;
}

C++: #include <iostream>

int main() {
  int n;
  int G[110][110];
  std::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) {
    int u, k;
    std::cin >> u >> k;
    u--;
    for(int j=0; j<k; ++j) {
      int v;
      std::cin >> v;
      v--;
      G[u][v] = 1;
    }
  }

  for(int i=0; i<n; ++i) {
    for(int j=0; j<n; ++j) {
      if(j != n-1) std::cout << G[i][j] << " ";
      else std::cout << G[i][j];
    }
    std::cout << std::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 <bits/stdc++.h>
using namespace std;




int main(){
  int n;
  cin >> n;
  vector<vector<int> > G(n, vector<int>(n,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] = 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++: public class Main{
    //directed graph
    List<Integer> adg[];
    Main(int n){
        adg = new LinkedList[n+1];
        for(int i = 0; i<=n; i++){
            adg[i] = new LinkedList<>();
        }
    }
    void addEdge(int index, int vertex){
        adg[index].add(vertex);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Maingraph = new Main(n);
        for(int i = 0; i<n; i++){
            int index = in.nextInt();
            int m = in.nextInt();
            for(int j = 0; j<m; j++){
                int temp = in.nextInt();
                graph.addEdge(index,temp);
            }
        }
        //change to matrix
        int[][] matrix = new int[n+1][n+1];
        for(int i = 1; i<=n; i++){
            if(graph.adg[i].size()!=0) {
                for (int c : graph.adg[i]) {
                    matrix[i][c] = 1;
                }
            }
        }
        for(int i = 1; i<=n; i++){
            for(int j = 1; j<=n; j++){
                if(j!=n) System.out.print(matrix[i][j]+ " ");
                else System.out.print(matrix[i][j]);
            }
            System.out.println();
        }

    }
}

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

int G[110][110];

int main() {
    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;
            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;
    }

    return 0;
}

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

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
  int M[N][N];  // 0 オリジンの配列
  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--;  // 0 オリジンへ変換
    for ( int j = 0; j < n; j++ ) {
      cin >> v;
      v--;  // 0 オリジンへ変換
      M[u][v];  // u と v の間に辺を張る
    }
  }

  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      if ( j ) cout << " ";
      cout << M[i][j];
    }
    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;
      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;
  }

  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;
#define MAX 100

int M[MAX][MAX];

int main(){
  int n,u,v,j;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>v;
    u--;
    for(int k=0;k<v;k++){
      cin>>j;
      M[u][--j]=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 <iostream>
#include <sstream>

int main () {
  int n;
  int k;
  int u1,u;
  std::cin>>n;
  int V[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      V[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    std::cin>>u1>>k;
    for(int j=0;j<k;j++){
      std::cin>>u;
      V[u1-1][u-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
      std::cout<<V[i][j]<<" ";
    }
    std::cout<<V[i][n-1]<<"\n";
  }
  return 0;
}