Go: package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}

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

using namespace std;

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix);

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

    vector<vector<int> > vertex(n, vector<int>(n, -1));
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;

        for (int j = 0; j < k; ++j)
            cin >> vertex[i][j];
    }

    vector<vector<int> > adjacent(n, vector<int>(n, 0));
    to_adjacent_matrix(vertex, adjacent);

    for (int i = 0; i < n; ++i) {
        cout << adjacent[i][0];
        for (int j = 1; j < n; ++j)
            cout << ' ' << adjacent[i][j];
        cout << '\n';
    }
}

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix)
{
    int n = adjacent_list.size();

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n && adjacent_list[i][j] != -1; ++j) {
            int adjacent = adjacent_list[i][j] - 1;
            if (adjacent <= 0 || adjacent > n)
                continue;

            adjacent_matrix[i][adjacent] = 1;
        }
    }
}

C++: #include <iostream>

using namespace std;

const int N = 100 + 1;

int main() {
    int A[N][N] = {{0}};

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u;
        cin >> u;

        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            A[u-1][x-1] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n, u, k, v;
  bool G[100][100] = {0};

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

  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cout << G[i][j]<< ' ';
    }

    cout << endl;
  }

  return 0;
}

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

int main() {
	int n, u, k, x;
	int matrix[101][101] = {};

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> x;
			matrix[u][x] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << matrix[i][j] ;
			if (j != n)	cout << " ";
		}
		cout << endl;
	}
	return 0;
}

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

C++: #include<iostream>
#include<stdio.h>
using  namespace std;
int main () {
    int n;
    int V[101][101] = { 0 };
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int u, c;
        scanf("%d %d", &u, &c);
        for (int j = 0; j < c; j++) {
            int ux;
            scanf("%d", &ux);
            V[u][ux] = 1;
        }
    }
    
    for (int i = 1; i < n+1; i++) {
        for (int j = 1; j < n+1; j++) {
            if (j != n) {
                printf("%d ", V[i][j]);
            }
            else {
                printf("%d" , V[i][j]);
            }
        }
        printf("\n");
    }
    
    
    return 0;
}

C++: #include <stdio.h>
#define N 101

int main(){

  int u,k,i,j,v,n;
  int a[N][N];
 
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(a[i][j]!=1)a[i][j]=0;
    }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][n]);
  }

  return 0;

}

C++: #include<iostream>
#include<vector>
using namespace std;
int judge(int i,int n,int variable,vector< vector<int> > &v)
{
  for(int j=0;j<v[variable].size();++j){
    if(i==v[variable][j]){
      return 1;
      break;
    }
  }
  return 0;
}
int main()
{
  int n,u,k,vv;
  cin>>n;
  vector< vector<int> > v(n),a(n,vector<int>(n));
  for(int variable=0;variable<n;++variable){
    cin>>u>>k;
    for(int i=0;i<k;++i){
      cin>>vv;
      v[variable].push_back(vv);
    }
  }
  for(int variable=0;variable<n;++variable)
    for(int i=1;i<=n;++i)
      a[variable][i-1]=judge(i,n,variable,v);
  for(int variable=0;variable<n;++variable){
    for(int i=0;i<n;++i){
      cout<<a[variable][i]<<" "<<flush;
    }
    cout<<endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  int u, k;
  int M[n][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;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      M[u - 1][v - 1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j < n - 1) cout << M[i][j] << ' ';
      else cout << M[i][j] << endl;
    }
  }
};