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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<vector<int>> graph(n, vector<int>(n, 0));
    rep(i, n) {
        int vertex, num;
        cin >> vertex >> num;
        rep(j, num) {
            int adjcent;
            cin >> adjcent;
            graph[vertex - 1][adjcent - 1] = 1;
        }
    }

    for (auto row : graph) {
        for (size_t i = 0; i < row.size(); i++) {
            cout << row[i];
            if (i != row.size() - 1) {
                cout << " ";
            } else {
                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 > 0) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int g[101][101];
int main(){
    int n,u,k,v;
    cin>>n;
    rep(i,n){
        cin>>u>>k;
        --u;
        rep(j,k){
            cin>>v;
            --v;
            g[u][v]=1;
        }
    }
    rep(i,n){
        rep(j,n) cout<<g[i][j]<<(j==n-1?"":" ");
        cout<<endl;
    }
    return 0;
}

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

int main(void){
  int m, a[100][100];
  int b[100][100]={0};

  cin >> m;

  for(int i=0; i<m; i++){
    cin >> a[i][0];
    cin >> a[i][1];

    for(int j=2; j<a[i][1]+2; j++){
      cin >> a[i][j];
      b[i][ a[i][j]-1 ] = 1;
    }
  }

  for(int i=0; i<m; i++){
    cout << b[i][0];
    for(int j=1; j<m; j++){
      cout << " " << b[i][j];
    }
    cout << "\n";
  }
  return 0;
}

C++: #include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int mp[10000][10000]={};

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


  return 0;

}

C++: #include<iostream>

using namespace std;

#define ll long long

int main(){
    ll n, u, k, v;
    cin >> n;
    ll A[n][n];
    for (ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            A[i][j] = 0;
        }
    }
    for(ll i=0; i<n; i++){
        cin >> u;
        cin >> k;
        for(ll j=0; j<k; j++){
            cin >> v;
            A[u-1][v-1] = 1;
        }
    }

    for (ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            cout << A[i][j];
        }
        if(i<n-1){
            cout << '\n';
        }
    }
}

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

using namespace std;

#define ll long long
typedef complex<double> P;

int main() {
  int n; cin >> n;
  int adj[n][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;
      adj[u-1][v-1] = 1;
    }

  }

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

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int mtx[100][100];
int main(void){
  int n;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int dg;
    cin >> dg >> dg;
    for (int j=0; j<dg; j++){
      int to;
      cin >> to;
      mtx[i][to-1]=1;
    }
  }
  
  for (int i=0; i<n; i++){
    cout << mtx[i][0];
    for (int j=1; j<n; j++){
      cout << " " << mtx[i][j];
    } cout << endl;
  }
  return 0;
}

C++: import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main{
    //directed graph
    LinkedList<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++: #include <iostream>
using namespace std;


int main(){
  int n;
  int u,k;
  int v;
  int map[100][100]={0};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v;
      map[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout << map[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

const int MAX_V = 100;

int main ( void )
{
  int n;
  int E[MAX_V][MAX_V];

  cin >> n;

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

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

    for (int i = 0; i < k; ++i) { cin >> v; E[u-1][v-1] = 1; }
  }
  
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
    cout << E[i][j] << (j+1 == n ? '\n' : ' ');
  }
  return 0;
}