Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			fmt.Printf(" %d", Adj[i][j])
			if j == n-1 {
				fmt.Println()
			}
		}
	}
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    int C[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            C[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        int u,k;
        scanf("%d %d",&u,&k);
        vector<int> v(k);
        for(auto&e:v){
            scanf("%d",&e);
        }
        for(int i=0;i<k;i++){
            C[u-1][v[i]-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j<n-1) printf("%d ",C[i][j]);
            else printf("%d\n",C[i][j]);
        }
    }

    return 0;
}

C++: #include<cstdio>

int main(void){
	int n, u, k, v;
	scanf("%d", &n);
	int a[n+1][n+1];
	for (int row = 1; row <= n; ++row) {
		for (int column = 1; column <= n; ++column)
			a[row][column] = 0;
	}
	for (int vertexi = 0; vertexi < n; ++vertexi) {
		scanf("%d %d", &u, &k);
		for (int outi = 0; outi < k; ++outi) {
			scanf("%d", &v);
			a[u][v] = 1;
		}
	}
	for (int row = 1; row <= n; ++row) {
		for (int column = 1; column <= n; ++column)	{
			if(column > 1)
				printf(" ");
			printf("%d", a[row][column]);
		}
		printf("\n");
	}
	return 0;
}

C++: //============================================================================
// Name        : Graph.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

void writeMatrix(vector<vector<int> > matrix){
	for(int i=0; i<matrix.size(); i++){
		for(int j=0; j<matrix.at(i).size()-1; j++){
			cout << matrix.at(i).at(j) << " ";
		}
		cout << matrix.at(i).at(matrix.at(i).size()-1);
		cout << "\n";
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<int> > matrix;

	for(int i=0; i<n; i++){
		vector<int> vec(n);
		matrix.push_back(vec);
	}

	for(int i=0; i<n; i++){
		int id, k;
		cin >> id >> k;
		for(int j=0; j<k; j++){
			int input;
			cin >> input;
			//cout << "id: " << id << ", k: " << k << "\n";
			matrix.at(id-1).at(input-1) = 1;
		}
	}

	writeMatrix(matrix);

	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int g[100][100];
int main(){
	int n;cin>>n;
	rep(i,n){
		int u,k;cin>>u>>k;u--;
		rep(j,k){
			int v;cin>>v;v--;
			g[u][v]=1;
		}
	}
	rep(i,n){
		rep(j,n){
			if(j)cout<<" ";
			cout<<[i][j];
		}
		cout<<endl;
	}
}

C++: // C++ 14
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>

#define ll long long
#define loop(x, start, end) for(int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)

using namespace std;


int main(void) {
  int n, v, c, l;
  cin >> n;

  int mat[n][n];

  loop(i,0,n) {
    loop(j,0,n) {
      mat[i][j] = 0;
    }
  }

  loop(i, 0, n) {
    cin >> v >> c;
    loop(j,0,c) {
      cin >> l;
      mat[v-1][l-1] = 1;
    }
  }

  loop(i,0,n) {
    loop(j,0,n) {
      if (j) cout << " ";
      cout << mat[i][j];
    }
    cout << endl;
  }
}

C++: #include<iostream>
#define MAX 101
using namespace std;


int main(){

	int adjMar[MAX][MAX];
	int n, i, j, vertice, degree, adjVertice;
	cin >> n;

	for (i = 0; i <= n; i++)
		for (j = 0; j <= n; j++)
			adjMar[i][j] = 0;

	for (i = 1; i <= n; i ++) {
		cin >> vertice;
		cin >> degree;
		for (j = 0; j < degree; j++){
			cin >> adjVertice;
			adjMar[vertice][adjVertice] = 1;
		}
	}

	for (i = 1; i <= n; i++){
		for (j = 1; j <= n; j++)
			cout << adjMar[i][j] << ' ';
		cout << endl;
	}
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
    int M[N][N];
    int n, u, k, v;
    
    cin >> n;
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    
    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++: class Main{
    //directed graph
    List<Integer> adg[];
    Main(int n){
        adg = new LinkedList[n+1];
        for(int i = 0; i<=n; i++){
            adg[i] = new LinkedList<>();
        }
    }
    void addEdge(int index, int vertex){
        adg[index].add(vertex);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Maingraph = new Main(n);
        for(int i = 0; i<n; i++){
            int index = in.nextInt();
            int m = in.nextInt();
            for(int j = 0; j<m; j++){
                int temp = in.nextInt();
                graph.addEdge(index,temp);
            }
        }
        //change to matrix
        int[][] matrix = new int[n+1][n+1];
        for(int i = 1; i<=n; i++){
            if(graph.adg[i].size()!=0) {
                for (int c : graph.adg[i]) {
                    matrix[i][c] = 1;
                }
            }
        }
        for(int i = 1; i<=n; i++){
            for(int j = 1; j<=n; j++){
                if(j!=n) System.out.print(matrix[i][j]+ " ");
                else System.out.print(matrix[i][j]);
            }
            System.out.println();
        }

    }
}

C++: //By Vlgd
#include<bits/stdc++.h>
using namespace std;
int G[101][101]={0};
main(){
	int n,u,v,deg;scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d%d",&u,&deg);
		for (int j=0;j<deg;j++){
			scanf("%d",&v);
			G[u][v]=1;
		}  
	}
	for(int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			printf("%d",G[i][j]);
			if (j==n) printf("\n");
			else printf(" ");
		}
	}
}

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

int a[102][102];
int main(){
	int n, u, k, t;
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d%d", &u, &k);
		for(int j = 0;j < k;j++){
			scanf("%d", &t);
			a[u][t] = 1;
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++)printf("%d ", a[i][j]);
		printf("\n");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


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

    vector<vector<int>> A(n, vector<int>(n));

    int u, d, v;
    rep(i, n)
    {
        cin >> u >> d;
        rep(j, d)
        {
            cin >> v;
            A.at(u - 1).at(v - 1) = 1;
        }
    }

    rep(i, n)
    {
        rep(j, n)
        {
            if (j == 0)
            {
                cout << A.at(i).at(j);
            }
            else
                cout << " " << A.at(i).at(j);
        }
        cout << endl;
    }
}