Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

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

#define int long long

const int N = 100 + 1;

int32_t main(){
  	int n;
  	cin >> n;
  	int g[n][n] = {};
  	for(int i = 0; i < n; i++){	
       int m, deg;
       cin >> m >> deg;
       for(int i = 0; i < deg; i++){
		  int x;
		  cin >> x;
		  g[m - 1][x - 1] = 1;
		}
    }
   for(int i = 0; i < n; i++){
	 for(int j = 0; j < n; j++){
		 if (j) cout << " ";
		 cout << g[i][j];
	   }
	  cout << endl;  
	 } 
}

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

using namespace std;

int main()
{
    int n, d, u, v, i, j, x;

    cin >> n;

    bool adjmat[n + 1][n + 1];

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

    for(i = 0; i < n; i++)
    {
        cin >> x >> d;
        for(j = 0; j < d; j++)
        {
            cin >> u;
            adjmat[x][u] = true;
        }
    }

    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= n; j++) {
            cout << adjmat[i][j];
            if(j < n)
                cout << " ";
        }
        cout << endl;
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(int argc, char const *argv[]) {
  int n,v,d; std::cin >> n;
  REP0(i,n){
    std::cin >> v >> d;
    VI row(n,0);
    REP0(j,d){
      std::cin >> v;
      row[v-1]=1;
    }
    REP0(j,n){
      std::cout << row[j];
      if (j<n-1) std::cout << " ";
    }
    std::cout << '\n';
  }

  return 0;
}

C++: #include <iostream>
#include <queue>

using namespace std;

#define MAX 110
int matrix[MAX][MAX];
int dst[MAX];

void input(int num){
    for(int i=0;i<MAX;i++){
        dst[i] = -1;
        for(int j=0;j<MAX;j++){
            matrix[i][j] = 0;
        }
    }
    for(int i=1;i<=num;i++){
        int v; cin >> v;
        int tmp; cin >>tmp;
        for(int j=0;j<tmp;j++){
            int vi; cin >> vi;
            matrix[v-1][vi-1] = 1;
        }
    }
}

void bfs(){

}

int main(){
    int num; cin >> num;
    input(num);

    for(int i=0;i<num;i++){
        for(int j=0;j<num;j++){
            if(j==0)
                cout << matrix[i][j];
            else
                cout << " " << matrix[i][j];
        }
        cout << endl;
    }

}