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;

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[101][101] = {0}, u, k, v;
  cin >> n;
  rep(i, n) {
    cin >> u >> k;
    u--;
    rep(j, k) {
      cin >> v;
      v--;
      a[u][v] = 1;
    }
  }

  rep(i, n) {
    rep(j, n) {
      if (j) cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

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


int main(){
	int n,a,b,c;
	cin >> n;

	int table[n][n];
	//??£??\??????????¢????

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			table[i][j] = 0;
		}
	}
	//??£??\??????????????????


	for(int i=0; i<n; i++){
		cin >> a >> b;
		if(b != 0){
			for(int j=0; j<b; j++){
				cin >> c;
				table[a-1][c-1] = 1;
			}
		}
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n-1; j++){
			cout << table[i][j] << " ";
		}
		cout << table[i][n-1] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <vector>

int main(){
	std::vector< std::vector<int> > M;
	int n, r, k, c;
	scanf("%d", &n);
	M.resize(n);
	for (int i=0;i<n;i++){
		M[i].resize(n);
		scanf("%d %d", &r, &k);
		for (int j=0; j<k;j++){
			scanf("%d", &c);
			M[i][c-1]=1;
		}
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			printf("%d", M[i][j]);
                        if (i!=n-1) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {

  int n,p,q;
  cin>>n;
  int a[100][100]={};
  for (int i=0;i<n;i++){
    cin>>q>>p;
    if (p!=0){
      for (int j=0;j<p;j++){
	a[i][j]=1;
      }
    }
  }
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        cin >> k-1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v-1;
            A[k][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;
    }
}

C++: #include <stdio.h>

int map_max;
int map[110][110];
int rows;
int cols[110];
int mat[110][110];

void get_map();
void print_map();
void conv_map();
void print_mat();

int main()
{

  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}

void get_map()
{

  int k;
  scanf("%d", &map_max);//<100

  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
	{
	  map[i][j]=0;
	  scanf("%d", &map[i][j]);
	}
    }

  
  return ;
}

void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  printf("%d", map[i][j]);
	}
      puts("");
    }
return ;
}


void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  if(map[i][j]!=0)
	    {
	  mat[i][map[i][j]-1]=1;
	    }
	}
    }
  return ;
}

void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
	{
	  printf("%d", mat[i][j]);
	  if(j!=map_max-1)
	    {
	      printf(" ");
	    }
	}
      printf("\n");
    }
}

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

int n;
vector<vector<int> > g;
int ans[101][101];

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

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100]={},v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i];
    int x;
    cin >> x;
    k[u[i]-1]+=x;

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<4; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      cout << " ";
      }

      cout << endl;
    }
  }

C++: #include <iostream>
#include <vector>
using namespace std;
vector<vector<int> > v(101);
int dp[101][2] = { 0 };
int n, t = 0;
 
void dfs(int a) {
    if (dp[a][0] == 0) { t++; dp[a][0] = t; }
    else { return; }
    for (int i = 0;i < v[a].size();i++) {
        if (dp[v[a][i]][0] == 0) {
            dfs(v[a][i]);
        }
    }
    if (dp[a][1] == 0) { t++; dp[a][1] = t; }
}
 
int main() {
    cin >> n;
    for (int i = 0; i < n;i++) {
        int u,k; cin >> u >> k;
        for (int j = 0; j < k;j++) {
            int x; cin >> x;
            v[u].push_back(x);
        }
    }
    for (int i = 1; i <= n;i++) {
        dfs(i);
    }
    for (int i = 1; i <= n;i++) {
        cout << i << ' ' << dp[i][0] << ' ' << dp[i][1] << endl;
    }
}

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

int n, u, k, uk;
int G[101][101] = {0};

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> u >> k;
		while (k --) {
			cin >> uk;
			G[u][uk] = 1;
		}
	}
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=n; ++j) {
			cout << G[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}