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] {
			fmt.Printf(" %d", Adj[i][j])
			if j == n-1 {
				fmt.Println()
			}
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j] << " ";
        }
        cout << endl;
    }
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int k,u;
    int v;
    int table[200][200]={};
    for(int i=0;i<n;i++){
        cin >> u;
        cin >> k;
        for(int j=0;j<k;j++){
            cin >> v;
            table[u-1][v-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j)cout << " ";
            cout << table[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;
typedef pair<int, int> P;

#define MAX 100005
#define INF INT_MAX

int main(int, char**)
{
    int n;
    cin >> n;

    vector< vector<int> > G(n, vector<int>(n,0));
    int u, k, v;
    rep(i,n) {
        cin >> u >> k; u--;
        rep(j,k) {
            cin >> v; v--;
            G[u][v] = 1;
        }
    }
    rep(i,n) {
        rep(j,n) {
            if (j) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	vector <vector<int>> a(n+1, vector<int>(n+1, 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;
			a[u][v]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << a[i][j];
			if (j != n) {
				cout << " ";
			}
		}
		cout << endl;
	}

}

C++: #include "bits/stdc++.h"
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--;
			for (int j = 0; j < k; ++j) {
				cin>>v;
				v--;
				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 <bits/stdc++.h>
using namespace std;

static const int MAX = 100;

int main(){
    int n;
    scanf("%d",&n);
    int u,k,adj[MAX][MAX],tmp;
    memset(adj,0,sizeof(adj));
    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(int m=0;m<k;m++){
            scanf("%d",&tmp);
            adj[i][tmp-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int m=0;m<n;m++){
            if(m) printf(" ");
            printf("%d",adj[i][m]);
            if(m==3) printf("\n");
        }
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int>> Adj(n,n);
    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++){
        cin>>k>>u;
        for(int j=0;j<u,j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

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

int main(int argc, char const *argv[])
{
    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<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int g[100][100];
int main(){
	int n;cin>>n;
	rep(i,n){
		int u,k;cin>>u>>k;u--;
		rep(j,k){
			int v;cin>>v;v--;
			g[u][v]=1;
		}
	}
	rep(i,n){
		rep(j,n){
			if(j)cout<<" ";
			cout<<a[i][j];
		}
		cout<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[105][105]={};
  cin >> 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;
      a[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout << " " ;
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include<cstdio>
const int max_n = 100;
int main(){
	int n;
	int 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;
		}
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&u,&k);
		for(int j=1;j<=k;j++){
			scanf("%d",&v);
			G[u-1][v-1] = 1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			printf("%d",G[i][j]);
			if(j!=n-1) printf(" ");
			else if(j == n-1) printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

int N;

int main()
{
	cin >> N;

	vector<vector<bool> > M(N, vector<bool>(N));

	int u, k, v;

	for (int i = 0; i < N; i++)
	{
		cin >> u >> k;

		for (int i = 0; i < k; i++)
		{
			cin >> v;

			M[u - 1][v - 1] = true;
		}
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N;)
		{
			cout << M[i][j];

			cout << ' ';
		}

		cout << endl;
	}

	return 0;
}