Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int n, adj[101][101];

int main()
{
  scanf("%d", &n);
  int u, k, v;
  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++)
  {
    scanf("%d%d", &u, &k);
    for(int j=0; j<k; j++)
    {
      scanf("%d", &v);
      adj[u][v] = 1;
    }
  }
  for(int i=1; i<=n; i++)
  {
    for(int j=1; j<=n; j++)
    {
      if(j!=1) printf(" ");
      printf("%d", adj[i][j]);
    }
    printf("\n");
  }



  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<iostream>
using namespace std;

int main()
{
    int n,k;
    int A[100][100]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int x;
            cin>>x;
            A[i][x]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==n-1&&j==n-1)
                cout<<A[i][j];
            else
                cout<<A[i][j]<<" ";
        }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<vector<int>>adj(n, vector<int>(n));
	for (int i = 0;i < n;i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0;j < k;j++) {
			int v;
			cin >> v;
			adj[u - 1][v - 1] = 1;
		}
	}
	for (int i = 0;i <n;i++) {
		for (int j = 0;j <n;j++) {
			if (j == 0) {
				cout << adj[i][j];
			}
			else {
				cout << " " << adj[i][j];
			}

		}
		cout << endl;
	}

}

C++: #include<bits/stdc++.h>

using namespace std;

typedef vector<int> vec;
typedef vector<vec> Graph;

int G[110][110];

int main()
{
	memset(G,0,sizeof(G));
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int u,t;
		scanf("%d%d",&u,&t);
		u--;
		for(int j=0;j<t;j++)
		{
			int v;
			scanf("%d",&v);
			v--;
			G[u][v]=1;
		}
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			printf("%d%c",G[i][j],j+1==n?'\n':' ');
	return 0;
}

C++: #include <iostream>

int main(void){
	int n;
	std::cin >> n;
	
	char list[101][101] = {0};
	
	int ci, cn, cval;
	for(int i=0; i<n; i++){
		std::cin >> ci >> cn;
		for(int j=0; j<cn; j++){
			std::cin >> cval;
			list[ci][cval] = 1;
		}
	}
	
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			std::cout << (int)list[i][j];
			if(j!=n) std::cout << ' ';
		}
		std::cout << '\n';
	}
	
	return 0;
}

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

int main()
{
  int n;
  int node,k,vi;
  int graph[100][100];

  cin >> n;
  memset(graph,0,sizeof(graph));
  
  for(int i=0;i < n;i++){
    cin >> node >> k;
    for(int j=0;j < k;j++){
      cin >> vi;
      graph[node-1][--vi] = 1;
    }
  }
  for(int i=0;i < n;i++){
    for(int j=0;j < n;j++){
      if(j) cout << " ";
      if(graph[i][j]) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}

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


int main(){

  int i,j,n,u[N],k[N];
  int Adj[N][N],t[N];


  scanf("%d",&n);

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


  for(i=0; i<n; i++){

    scanf("%d %d",&u[i],&k[i]);
    for(j=0; j<k[i]; j++){
      scanf("%d",&t[j]);

      Adj[u[i]][t[j]-1] = 1;
    }

  }


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

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

int main()
{
    int n; cin >> n;
    vector<vector<int>> graph(n);
    vector<vector<char>> A(n, vector<char>(n, '0'));
    int origin;
    for (int i = 0; i < n; ++i)
    {
        int u; cin >> u; u -= 1;
        int m; cin >> m;
        for (int k = 0; k < m; ++k)
        {
            int v;
            cin >> v;
            v -= 1;
            A[u][v] = '1';
        }
    }

    for (int i = 0; i < n; ++i)
    {
        for (int k = 0; k < n; ++k)
        {
            cout << A[i][k];
            if (k < n-1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

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

int n;
int M[101][101];
int main() {
    cin >> n;

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

    for (int l = 1; l <= n; ++l) {
        for (int i = 1; i <= n; ++i) {
            cout << " " << M[l][i];
        }
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <stdio>

using namespace std;

int main(){
  int g[10010][10010]={{0}};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
   {
     cin >> a >> b ;
     for (int i = 0; i < b; ++i)
     {
       cin >> c;
       g[a-1][c-1]=1;/* code */
     }
   }
   for (int i = 0; i < n; ++i)
   {
     for (int j = 0; j < n; ++i)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
   }

}

C++: #include <bits/stdc++.h>
using namespace std;
int n;
int a[101][101]={};
int u, k, s;
int main() 
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> u >> k;
		for(int j=0; j<k; j++)
		{
			cin >> s;
			a[u][s]=1;
		}
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			cout << a[i][j] << (j==n ? '\n' : ' ');
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int minimum=-1;


int main(){
	int n,row,num,col;
	scanf("%d",&n);
	int table[n][n];
	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++){
			table[i][k] = 0;
		}
	}

	for(int i=0;i<n;i++){
		scanf("%d %d",&row,&num);
		for(int k=0;k<num;k++){
			scanf("%d",&col);
			table[row-1][col-1]=1;
		}
	}

	for(int i=0;i<n;i++){
		for(int k=0;k<n-1;k++){
			printf("%d ",table[i][k]);
		}
		printf("%d\n",table[i][n-1]);
	}

    return 0;
}

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

int v,A[100][100],u,k,w;


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