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 <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
using Matrix = vector<vector<int>>;
Matrix d;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    d = Matrix(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;
            d[u][v-1] = 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(j!=n-1)cout << d[i][j] << " ";
            else cout << d[i][j] << endl;
        }

    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

void printarray(int n, int a[])
{
    for (int i = 1; i < n + 1; i++)
    {
        cout << a[i];
        if (i != n)
            cout << " ";
    }
    cout << endl;
}

int cycleanalysis(int n, int a[])
{
    int pos, ret, next;
    pos = 0, ret = 0;
    for (int i = 1; i < n + 1; i++)
    {
        pos = i;
        while (a[pos] != pos)
        {
            ret += (a[pos] + a[a[pos]]);
            next = a[pos];
            swap(a[pos], a[a[pos]]);
            pos = next;
        }
    }

    return ret;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, v, m, x;
    cin >> n;
    int a[n][n] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> v >> m;
        for (int j = 0; j < m; j++)
        {
            cin >> x;
            a[v-1][x - 1] = 1;
        }
        for (int k = 0; k < n; k++){
            cout << a[i][k];
            if (k != n-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int point_number;
	cin >> point_number;
	vector<vector<int>>v(point_number);
	for (int i = 0;i < point_number;i++) {
		int point;
		cin >> point;
		v[i].push_back(point);
		int rinsetu;
		cin >> rinsetu;
		v[i].push_back(rinsetu);
		for (int j = 0;j < rinsetu;j++) {
			int tunagari;
			cin >> tunagari;
			v[i].push_back(tunagari);
	


		}

	
	
	
}
	vector<vector<int>>ans(point_number,vector<int>(point_number));
	for(int i = 0;i < point_number;i++){
		for (int j = 0;j < v[i][1];j++) {
			ans[v[i][0]-1][v[i][j + 2]-1] = 1;
		}


	}
	for (int i=0;i < point_number;i++) {
		for (int j=0;j < point_number;j++) {
			if (j == 0) {
				cout << ans[i][j];
			}
			else {
				cout << " " << ans[i][j];
			}
		}
		cout << endl;
	}
	
}

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

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> g( n, vector<int>( 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++ ) {
			if( j ) cout << " ";
			cout << g[i][j];
		}
		cout << endl;
	}
}

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

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

    vector< vector<int> > G(n+5, vector<int>(n+5, 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][v] = 1;
        }
    }

    for(int i=1; i<=n; ++i){
        for(int j=1; j<=n; ++j){
            if(j != 1) cout << ' ';
            cout << G[i][j];
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 101;
int M[MAX][MAX];

int main()
{
    int n, m, s, v;
    cin >> n;
    for (int i = 0; i <= MAX; ++i)
    {
        for (int j = 0; j <= MAX; ++j)
        {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i != n; ++i)
    {
        cin >> m >> s;
        while (s--)
        {
            cin >> v;
            M[m][v] = 1;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            cout << M[i][j];
            if (j != n)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>> n;
  vector<vector<int> > v;
  v = vector<vector<int> >(n, vector<int>(n,0));
  for(int i=0; i<n; ++i){
    int tmp;
    cin >> tmp;
    cin >> tmp;
    for ( int j=0; j<tmp; ++j){
      int to;
      cin >> to;
      v[i][to-1] = 1;
    }
  }
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      cout << v[i][j];
      if( j != n-1) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}