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<iostream>
using namespace std;

int main(){
	int n,deg; cin>>n;
	int **vertex,**matrix;
	vertex = new int*[n]; for(int i=0;i<n;i++) vertex[i] = new int[n+1];
	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>>vertex[i][0];
		cin>>deg;
		for(int j=1;j<=deg;j++){
			cin>>vertex[i][j];
			matrix[vertex[i][0]-1][vertex[i][j]-1] = 1;
		}
	}

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

	for(int i=0;i<n;i++) delete [] vertex[i]; delete [] vertex;
	for(int i=0;i<n;i++) delete [] matrix[i]; delete [] matrix;
}

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

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

  vector<int> c(n);
  vector<vector<int>> M(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    int node;
    int d;
    cin >> node >> d;
    node--;

    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      M[i][tmp] = 1;
    }
  }

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

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

int n;
int M[101][101];
int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int v, k;
        cin >> v >> k;
        for (int j = 0; j < k; ++j) {
            int s;
            cin >> s;
            M[v][s] = 1;
        }
    }

    for (int l = 1; l <= n; ++l) {
        for (int i = 1; i <= n; ++i) {
            if (i)
            cout << M[l][i] << " ";
        }
        if (l != n)
        cout << endl;
    }

    return 0;
}

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

int g[100][100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, u, k, v;
    int i, j;
    cin>>n;
    for(i=0; i<n; i++) {
        cin>>u>>k;
        for(j=0; j<k; j++) {
            cin>>v;
            g[u-1][v-1]=1;
        }
    }
    for(i=0; i<n; i++) {
        cout<<g[i][0];
        for(j=1; j<n; j++) {
            cout<<' '<<g[i][j];
        }
        cout<<'\n';
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n; cin >> n;
  //adjacent matrix expression
  int a[n+1][n+1];
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      a[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    int u; cin >> u;
    int k; cin >> k;
    for(int i=0;i<k;i++){
      int v; cin >> v;
      a[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n-1;j++){
      cout << a[i][j] << " ";
    }
    cout << a[i][n] << endl;
  }
}

C++: #include<vector>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<vector<int>>v(n);
	for (int i = 0; i < n; i++)
	{
		int u;
		cin >> u;
		v[i].push_back(u);
		int k;
		cin >> k;
		v[i].push_back(k);
		for (int j = 0; j < k; j++)
		{
			int number;
			cin >> number;
			v[i].push_back(number);
		}
	}
	vector <vector<int>>answer(n, vector<int>(n));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			answer[i][j] = 0;
		}

	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < v[i].size()-2; j++)
		{
			answer[v[i][0]-1][v[i][2 + j]-1 ]= 1;
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cout << answer[i][j];
		}
		cout << endl;
	}
}
/*
1 2 2 4
2 1 4
3 0
4 1 3


*/

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

int main(){

  int n,n2,data,u;
  int g[N][N]; 
 //load n
  cin >>n;

  //initialize
  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++){
    scanf("%d%d",&u,&n2);
    for(int j=0;j<n2;j++){
      scanf("%d",&data);
      g[u][data]=1;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      printf("%d",g[i][j]);
      if(j!=n)printf(" ");
    }
    printf("\n");
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
  int m[100][100];
  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[i][j]=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>
using namespace std;
static const int N=100;

int main()
{
  int M[N][N];
  int n,u,k,v;
  int i,j;

  cin>>n;

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

  for(i=0;i<n;i++)
    {
      cin>>u>>k;
      u--;
      for(j=0;j<k;j++)
	{
	  cin>>v;
	  v--;
	  M[u][v]=1;
	}
    }

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

  return 0;
}

C++: #include<iostream>
int main(){
    int n;
    std::cin>>n;
    int A[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    int tmp,s,e;
    for(int i=0;i<n;i++){
        std::cin>>s;
        std::cin>>tmp;
        for(int j=0;j<tmp;j++){
            std::cin>>e;
            A[s-1][e-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            std::cout<<A[i][j]<<" ";
        }
        std::cout<<"\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N, vector<int>(N, 0));
    for (int i = 0; i < N; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u-1][v-1]++;
        }
    }
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << G[i][j] << ((j+1==N)?"\n":" ");
        }
    }
}