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<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    vector< vector<bool> > ans(n, vector<bool>(n, false));
    rep(i, n){
        int u, k;
        cin >> u >> k;
        --u;
        rep(j, k){
            int v;
            cin >> v;
            ans[u][--v] = true;
        }
    }

    rep(i, n){
        rep(j, n){
            if(j) cout << ' ';
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <set>
#include <vector>
#include <utility>

using namespace std;

typedef long long signed int ll;

constexpr ll NIL = -20000000000;

int g[101][101],n;

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) {
        int u,k,v;
        cin >> u >> k;
        for(int j = 0;j < k;j++) {
            cin >> v;
            g[u][v]++;
        }
    }
    for(int i = 1;i <= n;i++){for(int j = 1;j <n;j++)cout<<g[i][j] << " "; cout<<g[i][n] << endl;}
}

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

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

C++: #include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<string, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<vector<int>> res(n, vector<int>(n, 0));
    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--;
            res[u][v] = 1;
        }
        printv(res[u]);
    }
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	int n;
	int u, k, v;
	int gra[101][101] = {};

	cin >> n;
	
	FOR(i, 1, n) {
		cin >> u >> k;
		FOR(t, 1, k) {
			cin >> v;
			gra[u][v] = 1;
		}
	}
	FOR(i, 1, n) {
		FOR(t, 1, n) {
			cout << gra[i][t] << " ";
		}
		cout << endl;
	}
	return 0;
}

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

public class Main{
    //directed graph
    List<Integer> adg[];
    GraphAizu(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();
        Main graph = 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;
    cin >> n;
    int mat[n][n] = {};

    for(int i = 0; i < n; i++){
        int x, k, y;
        cin >> x >> k;
        while(k-- > 0){
            cin >> y;
            mat[x-1][y-1] = 1;
        }
    }

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

    return 0;
}