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>
using namespace std;

int main(){
  int a,b,c,d,g[101][101];
  cin>>a;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      g[i][j]=0;
    }
  }
  for(int i=0;i<a;i++){
    cin>>b>>c;
    for(int j=0;j<c;j++){
      cin>>d;
      g[b][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout<<g[i][j];
      if(a-j>=1)cout<<" ";
    }
    cout<<endl;
  }
  
  return 0;
}

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

int main(){
  int a,m[101][101],b,c,d;
  cin >> a;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      m[i][j]=0;
    }
  }
  for(int i=1;i<=a;i++){
    cin >> b >> c;
    for(int j=0;j<c;j++){
      cin >> d;
      m[i][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout << m[i][j];
      if(j!=a)cout<< " ";
    }
    cout << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,W;
int vx[]={1,0,-1,0};
int vy[]={0,1,0,-1};
int mt[102][102];
using namespace std;
void solve(){
    cin >> N ;
    int E,K;
    memset (mt,0,102*102);
    REP(i,N){
      cin >> E >> K;
      REP(j,K)
      {
        cin >> E;
        mt[i][E-1] = 1 ;
      }
    }
    REP(x,N){
      REP(y,N){
        cout << mt[x][y] ;
        if(x!=N-1&&y!= N-1)cout << ' '<<endl;
      }
      if(x!=N-1)cout << endl;
    }
}
int main(){

    solve();
}

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

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< vector< int > > adjMatrix (n, vector< int > (n, 0));
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int holder;
      cin >> holder;
      adjMatrix[u-1][holder-1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << adjMatrix[i][j];
      if (j == n-1)
	cout << endl;
      else
	cout << ' ';
    }
  }
  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) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }
}

C++: #include <iostream>

class Vertex {
public:
    int u, k, *v;
};

using namespace std;

int main() {
    int **matrix = nullptr, num = 0;
    Vertex *vertex;

    cin >> num;
    matrix = (int **)malloc(num * sizeof(int *));
    for(int i=0; i<num; ++i)
        matrix[i] = (int *)malloc(num * sizeof(int));
    
    for(int i=0; i<num; ++i) {
        for(int j=0; j<num; ++j) {
            matrix[i][j] = 0;
        }
    }
    
    vertex = new Vertex[num];
    for(int i=0; i<num; ++i) {
        cin >> vertex[i].u >> vertex[i].k;
        vertex[i].v = new int[vertex[i].k];
        for(int j=0; j<vertex[i].k; ++j) {
            cin >> vertex[i].v[j];
            matrix[vertex[i].u-1][vertex[i].v[j]-1] = 1;
        }
    }

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

    return 0;
}

C++: #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


//////////////////////////////////////
#include <iostream>
using namespace std;
#define dp(arg) do { cout << #arg << ":"; dprint(arg); } while(0)

template <typename T> void dprint(T arg) { cout << arg << "\n"; }
template <typename T> void dprint(const vector<T>& arg) { for_each(begin(arg), end(arg), [](T value){ cout << value << " "; }   ); cout << "\n";  }
template <typename T> void dprint(const vector<vector<T>>& arg) { for_each(begin(arg), end(arg), [=](vector<T> arg2){ dprint(arg2); cout << "\n";} );  }

// #define dprint(arg) ;
//////////////////////////////////////

using namespace std;
int main() {

    int n;
    cin >> n;

    int adj[n][n];
    memset(adj, 0, sizeof(int) * n * n);

    int v, k;
    int a;
    REP(i, n) {
        cin >> v >> k;
        REP(j, k){
            cin >> a;
            adj[v-1][a-1] = 1;
        }
    }

    REP(i, n) {
        REP(j, n - 1) {
            cout << adj[i][j] << " ";
        }
        cout << adj[i][n-1] << "\n";
    }

}