Go: package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	graph := make([][]int, N)
	for i := range graph {
		graph[i] = make([]int, N)
		var u, k int
		fmt.Scan(&u, &k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			v--
			graph[i][v] = 1
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if j > 0 {
				fmt.Print(" ")
			}
			fmt.Print(graph[i][j])
		}
		fmt.Println()
	}
}

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

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

bool G[100][100];

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

    rep(i, N) {
        int u, k, v;
        cin >> u >> k;
        rep(j, k) {
            cin >> v;
            G[u-1][v-1] = true;
        }
    }

    rep(i, N) {
        rep(j, N) {
            if (j > 0) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;


static const int N = 100;

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

  cin >> n;
  REP(i,n){
    REP(j,n){
      M[i][j] = 0; //初期化
    }
  }

REP(i,n){
  cin >> u >> k;
  u--;  //オリジンに変換
  
  REP(j,k){
    cin >> v;
    v--;
    M[u][v] = 1;
  }
}

REP(i,n){
  REP(j,n){
    if(j) cout << " ";
    cout << M[i][j];

  }
  cout << endl;
}


return 0;


}

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

int ari;
int jigoku[102];
int u[102];
int v[102][102];
int ushi[102][102];
int main(){
  cin>>ari;
  for(int i=1;i<ari+1;i++){
    cin>>u[i]>>jigoku[u[i]];
      for(int j=1;j<jigoku[u[i]]+1;j++){
	cin>>v[u[i]][j];
      }
  }
  //for(int uma=1;uma<ari+1;uma++){cout<<u[uma];}
  for(int k=1;k<ari+1;k++){
    for(int l=1;l<jigoku[k]+1;l++){
      for(int m=1;m<ari+1;m++){
	//cout<<v[k][l];
	if(v[k][l]==u[m]){ushi[k][m]=1;}
	//cout<<ushi[k][m];
      }
    }
  }
    for(int k=1;k<ari+1;k++){
      for(int m=1;m<ari;m++){
	cout<<ushi[k][m]<<" ";
      }cout<<ushi[k][ari];
      cout<<endl;}
}

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

int main()
{
    int n, u, k, v;

    cin >> n;

    bool 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 >> k;
        for( int j = 0; j < k; j++ )
        {
            cin >> v;
            a[u-1][v-1] = 1;
        }
    }

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

    return 0;
}