Go: package main

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

func main() {
	var n int
	fmt.Scanf("%d", &n)

	adj := make([][]string, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]string, n)
		for j := 0; j < n; j++ {
			adj[i][j] = "0"
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		sc.Scan()
		adjList := strings.Split(sc.Text(), " ")
		outDegree, _ := strconv.Atoi(adjList[1])

		if outDegree > 0 {
			for k := 0; k < outDegree; k++ {
				j, _ := strconv.Atoi(adjList[k+2])
				adj[i][j-1] = "1"
			}
		}
	}

	for i := 0; i < len(adj); i++ {
		fmt.Println(strings.Join(adj[i], " "))
	}

}

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) {
                    if(j!=n){
                        cout << 1 <<" "; hantei=1;
                    }else{
                        cout << 1 ;
                    }    
                }
            }
            if(hantei==0){ 
                if(i!=n){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            };
        }cout << endl;
    }
}

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

using namespace std; 

int main(void) {
	int nov,noe,u,v;
	cin >> nov;
	vector< vector<int> > adj(nov,vector<int>(nov,0));
	for (int i = 0; i < nov; ++i) {
		cin >> u;
		cin >> noe;
		for (int j = 0; j < noe; ++j) {
			cin >> v;
			adj[u-1][v-1] = 1;
		}
	}
	for (int i = 0; i < nov; ++i) {
		for (int j = 0; j < nov; ++j) {
			cout << adj[i][j];
			if (j < nov-1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#define MAX 101

using namespace std;

int main(){
  int n, i, j, k, l, m;
  bool g[MAX][MAX];
  
  for(i=1;i<MAX;++i){
    for(j=1;j<MAX;++j)
      g[i][j] = false;
  }
  
  cin >> n;
  for(i=1;i<=n;++i){
    cin >> k >> l;
    for(j=1;j<=l;++j){
      cin >> m;
      g[k][m] = true;
    }
  }
  
  for(i=1;i<=n;++i){
    for(j=1;j<=n;++j){
      cout << g[i][j];
      if(n != j)cout << " ";
    }
    cout << "\n";
  }
  
  return 0;
}

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

int main(void){
    int n;
    int ind, num, a;
    std::cin >> n;
    std::vector<std::vector<int>> b(n, std::vector<int>(n));
    for(int i = 0; i < n; i++){
        std::cin >> ind >> num;
        ind--;
        for(int i = 0; i < num; i++){
            std::cin >> a;
            a--;
            b[ind][a] = 1;
        }
        
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j != 0){
                std::cout << " " << b[i][j];
            }else{
                std::cout << b[i][j];
            }
        }
        std::cout << std::endl;
    }
    return 0;
}

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

int main(int argc, char const *argv[]) {
  int n;  cin >> n;
  vector<vector<int> > a(n, vector<int>(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) {
      cout << a[i][j];
      if (j < n - 1) {
        cout << " ";
      }
    }
    cout << '\n';
  }
  return 0;
}