Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

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;
    }
}