Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

C++: #include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <deque>
#include <vector>
#define MAX 10010
#define rep(i,p) for(int i=0;i<p;i++)
#define pb push_back
using namespace std;
int n,hoge,foo;
int graph[MAX][MAX] = {0};
int main(){
  cin >> n;
  rep(i,n) {
    cin >> hoge >> foo;
    rep(j,foo) {
      cin >> hoge;
      graph[i][hoge-1] = 1;
    }
  }
  rep(i,n) {
    rep(j,n) cout << graph[i][j] << " ";
    cout << endl;
  }
  return 0;
}

C++: #define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>




int main(int argc, const char * argv[]){
    
    //Input
    int i, j , n ,m , frm, to;
    
    scanf("%d", &n);
    
    int ans[n][n];
    
    memset(ans, 0x00, sizeof(ans));
    
    for(i = 0; i < n; i++){
        
        scanf("%d", &frm);
        scanf("%d", &m);
        
        for (j=0; j<m; j++) {
            scanf("%d", &to);
            ans[frm - 1][to - 1] = 1;
        }
        
    }
    
    for (i=0; i<n; i++) {
        for (j=0; j<n; j++) {
            printf("%d", ans[i][j]);
            if(j != n-1) printf(" ");
        }
        printf("\n");
    }
    
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
#define N 100

int main(){
    int graph[N][N];
    int n;
    int c,l; 
    int arc; 
    cin >> n;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            graph[i][j] = 0;
    
   for(int i=0;i<n;i++){
        cin >> c;
        cin >> arc;
        for(int j=0;j<arc;j++){
            cin>> l;
            graph[c-1][l-1]=1;
        }
    }

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

C++: #include "stdio.h"
#include<iostream>

using namespace std;

int main(void){

  int N;
  scanf("%d", &N);

  int node_num, dimention, adjacency_node_num;  
  
  int** matrix = new int* [N];
  for(int i=0;i<N;i++){
    matrix[i] = new int [N];
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      matrix[i][j] = 0;
    }
  }

  for(int i=0;i<N;i++){
    cin >> node_num >> dimention;

    for(int i=0;i<dimention;i++){
      cin >> adjacency_node_num;
      matrix[node_num-1][adjacency_node_num-1] = 1;
    } 
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(j != 0){
        printf(" ");
      }
      printf("%d", matrix[i][j]);
    }
    printf("\n");
  }

  for(int i=0;i<N;i++){
    delete [] matrix[i];
  }

  delete [] matrix;  

  return 0;
}

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

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

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, a[101][101] = {};
    cin >> n; 
    for (int i = 1; i <= n; i++) {
        int p,m;
        cin >> p>>m;
        if (p != i) continue;
        for (int j = 0; j < m; j++) {
            int k;
            cin >> k;
            a[i][k]++;
        }
    }
    for (int i = 1;i <= n;i++) {
        for (int j = 1; j <= n;j++) {
            if (j-1) cout << " ";
            cout << a[i][j];
        }
        cout << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    int graph[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            graph[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int a,temp;
        cin>>a>>temp;
        for(int j=0;j<temp;j++)
        {
            int k;
            cin>>k;
            graph[i][k]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int j;
        for(j=1;j<n;j++)
        {
            cout<<graph[i][j]<<' ';
        }
        cout<<graph[i][j]<<endl;
    }
    return 0;
}

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

int G[110][110] ={0};

int main(){
  int n;
  cin >> n;
  int u, k;
  int v[100000];
  for(int i=0; i<n; i++){
    cin >> u >> k;
    for(int j=0; j<k; j++){
      cin >> v[j];
      G[i][v[j]] = 1;
    }
  }
  for(int i=0; i<n; i++){
    for(int j=1; j<n+1; j++){
      cout << G[i][j] << " ";
    }
    cout << 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 <iostream>
#include "string.h"
using namespace std;
int m[107][107];
int main(int argc, char *argv[]) {
	int n,u,k,v;
	cin>>n;
	memset(m, 0, sizeof(m));
	for(int i=1;i<=n;i++)
	{
		cin>>u>>k;
		for(int j=1;j<=k;j++)
		{
			cin>>v;
			m[u][v]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			
			cout<<m[i][j];
			if(j!=n)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

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


using namespace std;


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


  vector< vector<int> > a;
  for(int i=0;i<n;i++){
    int u;
    int k;
    cin >> u >> k;
    vector<int> tmpa;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      tmpa.push_back(tmp);
    }

    a.push_back(tmpa);
  }

  
  
  int a2[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a2[i][j]=0;
    }
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<(int)a[i].size();j++){
      a2[i][a[i][j]-1] = 1;
    }
  }

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