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"iostream"
#include"vector"
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector< vector<int> > matrix (n, vector<int>(n) );
  vector<int> visit;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)matrix[i][j]=0;
      int y;
      cin>>y;
      int num;
      cin>>num;
      for(int j=0;j<num;j++)
        {
          int x;
          cin>>x;
          matrix[y-1][x-1]=1;
        }
    }
  for(int i=0;i<n;i++)
    {
      cout<<matrix[i][0];
      for(int j=1;j<n;j++)
        {
          cout<<" "<<matrix[i][j];
        }
      cout<<endl;
    }
  return 0;
}

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

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

}

C++: #include <iostream>

using namespace std;

int main()
{
        int n, u, k, v;
        int g[100][100];

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

        return 0;
}

C++: #include <array>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)



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

    int mat[100][100];
    REP(i, n) {
        REP(j, n) {
            mat[i][j] = 0;
        }
    }

    REP(_, n) {
        int u, k;
        cin >> u >> k;

        REP(_, k) {
            int v;
            cin >> v;
            mat[u-1][v-1] = 1;
        }
    }

    REP(i, n) {
        REP(j, n) {
            cout << mat[i][j];
            cout << (j == n-1 ? '\n' : ' ');
        }
    }

    return 0;
}

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

int main() {

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

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    while(k>0){
      scanf("%d",&l);
      a[u][l] = 1;
      k--;
    }
  }

  for(i=1;i<=n;i++) {
    for(j=1;j<=n;j++){
      if(j == n) {
	printf("%d",a[i][j]);
      }else{
	printf("%d ",a[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++: #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>

using namespace std;


int main() {
	int n;
	int u, v;
	int Adj[101][101];
	int deg;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			Adj[i][j] = 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		cin >> u;
		cin >> deg;
		for (int j = 1; j <= deg; j++) {
			cin >> v;
			Adj[u][v] = 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			printf(" %d", Adj[i][j]);
		}
		printf("\n");
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int g[n + 1][n + 1];
    //?????????
    for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= n; j++) {
	    g[i][j] = 0;
	}
    }
    //input
    for (int i = 1; i <= n; i++) {
	int a;
	cin >> a;
	int b;
	cin >> b;
	for (int j = 1; j <= b; j++) {
	    int c;
	    cin >> c;
	    g[a][c] = 1;
	}
    }
    for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= n; j++) {
	    cout << g[i][j] << " ";
	}
	cout << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int a[101][101];
void init(int n){
	for (int i = 1;i <= n;i++){
		for (int j = 1;j <= n;j++){
			a[i][j] = 0;
		}
	}
}
int main()
{
	int n;
	while (cin >> n){
		init(n);
		int x,m,y;
		for (int i = 1;i <= n;i++){
			cin >> x >> m;
			while (m--){
				cin >> y;
				a[x][y] = 1;
			}
		}
		for (int i = 1;i <= n;i++){
			for (int j = 1;j <= n;j++){
				cout << a[i][j] << " ";
			}
			cout << endl;
		}
	}
	return 0;
}

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

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

    vector<vector<int>> adj(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++)
    {
        int a, k;
        cin >> a >> k;
        for (int j = 0; j < k; j++)
        {
            int x;
            cin >> x;
            adj[a - 1][x - 1] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int g[1001][1001]={{0}};//要素を0で初期化
  int n,a,b,c;
  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 >> 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; ++j)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
  }

}