Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

C++: //Aizu11A 16D8104015E Nobushige Sen 18.6.22

#include<iostream>
using namespace std;
 
int x[15000][15000],n,q,r,b;
 
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> q >> r;
        for (int j = 0; j < r; j++) {
            cin >> b;
            x[i][b] = true;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) { cout << ' '; }
            cout << x[i][j+1];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
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;}

int main () {
  int n = in();
  vvi a(n,vi(n));
  rep(i,n) {
    int u, k;
    cin >> u >> k;
    u--;
    rep(j,k) {
      int v;
      cin >> v;
      v--;
      a[u][v] = 1;
    }
  }
  rep(i,n)rep(j,n) printf("%d%c", a[i][j], j == n-1 ? '\n' : ' ');
  return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#pragma warning (disable:4996)

int main()
{
	int num = 0;
	while (scanf("%d",&num)!=EOF)
	{
		int arr[102][102] = { 0 }, ans[102][102] = { 0 };
		for (int i = 0; i < num; i++)
		{
			scanf("%d %d", &arr[i][0], &arr[i][1]);
			int temp = 2;
			for (int j = 0; j < arr[i][1]; j++)
			{
				scanf("%d", &arr[i][temp]);
				temp++;
			}
		}
		for (int i = 0; i < num; i++)
		{
			int temp = 2;
			for (int j = 0; j < arr[i][1]; j++)
			{
				ans[i][arr[i][temp] - 1]++;
				temp++;
			}
			printf("%d", ans[i][0]);
			for (int j = 1; j < num; j++)
			{
				printf(" %d", ans[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

#include<string>
#include<cmath>
#include<map>
//#include<cstdlib>
#include<deque>
//#include<queue>
//#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j];
      if(j!=N-1) cout << " ";
      else cout << endl;
    }
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}