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>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
void out(vector<vector<int>> vec,int n){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << vec[i][j] ;
            if(j!=n-1){
                cout <<" " ;
            }
        }
        cout << endl ;
    }
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


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 ll ;
      cin >> ll ;
      int k ;
      cin >> k ;
      REP(j,k){
          int l ;
          cin >> l ;
          graph[ll-1][l-1] = 1 ;
      }
  }
  
  out(graph,n) ;
  
  
  
  return 0 ;
}

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

bool find(vector<int> v, int j){
    bool e = false;
    for(vector<int>::iterator it = v.begin(); it!=v.end(); ++it){
        if (*it == j) e = true;
    }
    return e;
}

int main(){
    vector<int> adj[MAXN];
    int n; cin >> n;
    for(int i=1; i<=n; ++i){
        int l, m; cin >> l >> m;
        for(int j=0; j<m; ++j){
            int k; cin >> k;
            adj[l].push_back(k);
        }
    }
    
    for(int i=1; i<=n; ++i){
        for(int j=1; j<=n; ++j){
            cout << (find(adj[i], j) ? 1 : 0 );
        }
        cout << endl;
    }
}

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

int main(void){
    int n; cin >> n;
    bool graph[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) graph[i][j]=false;
    }
    for(int i=0; i<n; i++){
        int v,k; cin >> v >> k;
        for(int j=0; j<k; j++){
            int w; cin >> w;
            graph[v-1][w-1]=true;
        }
    }

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

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

int main(){

    ll N;
    cin >> N;

    vector<vector<ll> > G(N,vector<ll>(N,0));
    for (int i = 0; i < N; i++)
    {
        ll u,k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            ll v;
            cin >> v;
            G[u-1][v-1] = 1;
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << G[i][j] ;
            if( j != N-1 )
                cout << " ";
        }
        cout << endl;
        
    }
    
    




}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

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

	int n;
	cin >> n;

	int g[n][n] = {};
	for(int i=0;i<n;i++){
		int u, nume;
		cin >> u >> nume;

		int v;
		for(int j=0;j<nume;j++){
			cin >> v;
			g[u-1][v-1]= 1;
		}

	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout << g[i][j];
			if(j != n-1) cout << " ";
		}
		cout << "\n";
	}
	
	return 0;
}

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

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

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

    return 0;
}

C++: 
import java.util.Scanner;
import java.util.ArrayList;


class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}

	void solve(){
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int [][] ar = new int[n][n];

		for(int i = 0; i < n; i++){
			int u = in.nextInt() - 1, k = in.nextInt();
			for(int j = 0; j < k; j++){
				int v = in.nextInt() -1;
				ar[u][v] = 1;
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(j != 0) System.out.print(" ");
				System.out.print(ar[i][j]);
			}
			System.out.println("");
		}

	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  
 //とても大きい値を無限としておく。
  int n;
  cin >> n;  //Vは与えられた頂点数,Eは辺の数
  vector<vector<int>> a(n,vector<int>(n,0));//V*Vを無限で初期化
  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--;
      a[u][v]=1;
    }
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      cout<<a[i][j];
      if(j!=j-1){
        cout<<" ";
      }
    }
    cout<<endl;
  }
}