Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

C++: #include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) cout << exchange(dlm, " ") << x;
  return os;
}
int32_t main(){
  size_t n; cin>>n;
  vector<vector<size_t>> adj(n);
  for(size_t i=0; i<n; ++i){
    size_t u,k; cin>>u>>k;
    adj[u-1].resize(k);
    for(auto&& x:adj[u-1]) cin>>x;
  }
  vector<vector<size_t>> m(n,vector<size_t>(n,0));
  for(size_t i=0; i<n; ++i){
    for(const auto& x:adj[i]) m[i][x-1]=1;
  }
  for(const auto& x:m) cout<<x<<endl;
}

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

int G[110][110];

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

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

C++: #include<stdio.h>
using namespace std;
static const int N = 100;
int main() {
    
    int n, u, k, v;
    int M[N][N];
    
    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[i][j] = 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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
using namespace std;
int  v[102][101], n;
int main() {
	int u, k, s;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			v[u][s] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j > 1) cout << " ";
			cout << v[i][j];
		}
		cout << endl;
	}	return 0;
}

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

#define MAX 100
int main() {
	int n = 0;
	scanf("%d", &n);
	int M[MAX][MAX] = { 0 };
	for (int i = 0; i < n; i++) {
		int u, k;
		scanf("%d%d", &u, &k);
		u--;
		for (int j = 0; j < k; j++) {
			int v = 0;
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) printf(" ");
			printf("%d",M[i][j]);
		}
		printf("\n");
	}
	return 0;

}

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;
  }
}