Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

C++: #include <iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	int u,k;
	int v[k];
	int G[N][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>>u>>k;
		for(int j=0;j<k;++j){
			cin>>v[j];
			G[u-1][v[j]-1]=1;  //??£??\????????????ID??§??????"u"???1???????§????????????§?????????????????????u-1??¨??????
		}	
	}
	for(int i=0;i<N;++i){
		for(int j=0;j<N;++j){
			cout <<G[j][i]<< " ";
		}
		cout<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
    int n, node, d, p;
    cin >> n;
    int a[n][n];
    rep(i, n)rep(j, n) a[i][j] = 0;
    rep(i, n){
        cin >> node >> d;
        rep(i, d){
            cin >> p;
            a[node - 1][p - 1] = 1;
        }
    }
    rep(i, n){
        rep(j, n){
        if(j) cout << " ";
        cout << a[i][j];
        }
        cout << endl;
    }
}

C++: #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<bits/stdc++.h>
using namespace std;
int M[101][101];
int main(){
  int n,u,k,v;
  cin>>n;
  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>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

#include<string>
//#include<cmath>
//#include<map>
//#include<cstdlib>
#include<deque>
//#include<queue>
//#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j];
      if(j!=N-1) cout << " ";
      else cout << endl;
    }
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}

C++: #include <stdio.h>
#define N 100
int main(){
  int n,i,j,u,k,v,M[N][N];

  scanf("%d",&n);

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

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

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

C++: #include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

#include<string>
#include<cmath>
#include<map>
//#include<cstdlib>
#include<deque>
#include<queue>
#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j];
      if(j!=N-1) cout << " ";
      else cout << endl;
    }
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,a,b,c;
  int G[100][100] = {0};
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cin >> a >> b;
    a--;
    for(int i = 0 ; i < b ; i++){
      cin >> c;
      c--;
      G[a][c] = 1;
    }
    }
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      if(j == 0)cout << G[i][j];
      cout <<" "<< G[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
    vector<int> l[101];
    int matrix[100][100];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            int tmp;
            cin>>tmp;
            l[u].push_back(tmp);
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            matrix[i][j]=0;
        }
    }
    
    for(int i=1;i<n+1;i++)
    {
        for(int j=0;j<l[i].size();j++)
        {
            matrix[i-1][l[i][j]-1]=1;
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<matrix[i][j]<<" ";
        }
        cout<<endl;
    }
}