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

int main()
{
  int n;
  int node,k,vi;
  int graph[100][100];

  cin >> n;
  memset(graph,0,sizeof(graph));
  
  for(int i=0;i < n;i++){
    cin >> node >> k;
    for(int j=0;j < k;j++){
      cin >> vi;
      graph[node-1][--vi] = 1;
    }
  }
  for(int i=0;i < n;i++){
    for(int j=0;j < n;j++){
      if(j) cout << " ";
      if(graph[i][j]) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int G[100][100] = {0};
queue<int> v;

void adjacent(int u, int k){
    int j;
    for(int i=0; i<k; i++){
        j = v.front(); v.pop();
        G[u-1][j-1] = 1;
    }
}

int main(){
    int n; cin >> n;
    int u, k, num;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int i=0; i<k; i++){
            cin >> num;
            v.push(num); 
        }
        adjacent(u, k);
    }

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

    return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;

    vector<vector<int>> table(N, vector<int>(N, 0));
    REP(i,N){
        ll u, k;
        cin >> u >> k;
        REP(j,k){
            ll v;
            cin >> v;
            table[u-1][v-1] = 1;
        }
    }

    REP(i, N){
        REP(j, N){
            printf("%d%c", table[i][j], (j == N-1)?'\n':' ');
        }
    }
}

C++: #include<stdio.h>

#define MAX 100

int main(){
  int i,j,n,M[MAX][MAX],l,u,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&l);
      M[u-1][l-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",M[i][j]);
      if(j<n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

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

int main(){

  int N,u,k,v;
  cin>>N;
  int graph[N][N];

  //init
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      graph[i][j]=0;

  for(int i=0;i<N;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      graph[u-1][v-1]=1;
    }
  }

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

C++: #include <iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	int u,k;
	int v[k];
	int G[N][N];
	for(int i=0;i<N;++i)
		for(int j=0;j<N;++j)
			G[i][j]=0; //?????????
	for(int i=0;i<N;++i){
		cin>>u>>k;
		for(int j=0;j<k;++j){
			cin>>v[j];
			G[v[j]-1][u-1]=1;  //??£??\????????????ID??§??????"u"???1???????§????????????§?????????????????????u-1??¨?????????
		}	
	}
	for(int i=0;i<N;++i){
		for(int j=0;j<N-1;++j){
			cout <<G[j][i]<< " ";
		}
		cout<< G[N-1][i]<<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


static const int N = 100;


int main()
{
	int M[N][N];
	int n, u, k, v;
	
	cin >> n;
	rep(i, n) rep(j, n) M[i][j] = 0;
	rep(i, n)
	{
		cin >> u >> k;
		u--;
		rep(j, k)
		{
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	
	rep(i, n)
	{
		rep(j, n)
		{
			if (j) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

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

C++: #include<iostream>
using namespace std;
static const int N=100;
int M[N+1][N+1];
int main(){
    int n,u,k,v;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>u>>k;
        for(int j=1;j<=k;j++){
            cin>>v;
            M[u][v]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)
            cout<<(j>1?" ":"")<<M[i][j];
        cout<<"\n";
    }
    return 0;

}

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!=n-1){
        cout<<" ";
      }
    }
    cout<<endl;
  }
}