Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	n := nextInt()
	v := make([][]int, n)
	for i := 0; i < n; i++ {
		u := nextInt()
		k := nextInt()
		for j := 0; j < k; j++ {
			v[u-1] = append(v[u-1], nextInt())
		}
	}

	for _, vvs := range v {
		for j := 1; j <= n; j++ {
			if j > 1 {
				fmt.Fprint(w, " ")
			}
			p := sort.SearchInts(vvs, j)
			if p < len(vvs) && vvs[p] == j {
				fmt.Fprint(w, 1)
			} else {
				fmt.Fprint(w, 0)
			}
		}
		fmt.Fprintln(w)
	}

	w.Flush()
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define NIL -1

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;

bool binary_search(int a[], int n, int key)
{
    int l = 0;
    int r = n;
    int middle;
    while (l < r)
    {
        middle = (l + r) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            l = middle + 1;
        }
        else if (key < a[middle])
        {
            r = middle;
        }
    }
    return false;
}

int main()
{
    int M[100][100];
    int n, u, k, v;

    cin >> n;

    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            M[i][j] = 0;
        }
    }

    rep(i, 0, n)
    {
        cin >> u >> k;
        u--;
        rep(j, 0, k)
        {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

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

C++: #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int n,u,k,v;
	cin>>n;
	int G[110][110];
	memset(G,0,sizeof(G));
	for(int i=0;i<n;++i){
		cin>>u>>k;
		u--;//转化成0起点
		for(int j=0;j<k;++j){
			cin>>v;
			v--;
			G[u][v]=1;//u和v之间画一条边 
		} 
	} 
	for(int i=0;i<n;++i){
		for(int j=0;j<n;j++){
			if(j>0)cout<<' ';
			cout<<G[i][j]; 
		}
		cout<<endl;
	}
	//cout<<endl;
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<vector<int>> mat(n, vector<int>(n));
    rep(i, n) {
        int u, k, v;
        cin>>u>>k; u--;
        rep(j, k) {
            cin>>v; v--;
            mat[u][v] = 1;
        }
    }
    rep(i, n) {
        rep(j, n - 1) cout<<mat[i][j]<<" ";
        cout<<mat[i][n - 1]<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int T[100][100];

void init(){
	for (int i = 0; i < 100; ++i)
	{
		for (int j = 0; j < 100; ++j)
		{
			T[i][j] = 0;
		}
	}
}

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

int main(){
	int n;
	cin >> n;
	init();
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			if(T[v-1][u-1] == 0) T[u-1][v-1] = 1;	
		}
	}
	DispTable(n);
	return 0;
}

C++: #include"iostream"
#include"vector"
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector< vector<int> > matrix (n, vector<int>(n) );
  vector<int> visit;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)matrix[i][j]=0;
      int y;
      cin>>y;
      int num;
      cin>>num;
      for(int j=0;j<num;j++)
        {
          int x;
          cin>>x;
          matrix[y-1][x-1]=1;
        }
    }
  for(int i=0;i<n;i++)
    {
      cout<<matrix[i][0];
      for(int j=1;j<n;j++)
        {
          cout<<" "<<matrix[i][j];
        }
      cout<<endl;
    }
  return 0;
}

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

int main(){
    int N,u,k,x;
    cin>>N;
    
    int array[N][N];
    for(int i=0;i<N;i++){for(int j=0;j<N;j++){array[i][j]=0;}}
    
    for(int i=0;i<N;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>x;
            array[u-1][x-1]=1;
        }
    }
    
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(j!=0){
                    cout<<" ";
                }
                cout<<array[i][j];
            }
            cout<<"\n";
        }
        
        return 0;

}

C++: #include <iostream>

using namespace std;

int main()
{
        int n, u, k, v;
        int g[100][100];

        for (int i = 0; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                        g[i][j] = 0;
                }
        }
        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> u >> k;
                if (k > 0) {
                        for (int j = 0; j < k; 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 << endl;
        }

        return 0;
}

C++: #include <array>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)



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

    int mat[100][100];
    REP(i, n) {
        REP(j, n) {
            mat[i][j] = 0;
        }
    }

    REP(_, n) {
        int u, k;
        cin >> u >> k;

        REP(_, k) {
            int v;
            cin >> v;
            mat[u-1][v-1] = 1;
        }
    }

    REP(i, n) {
        REP(j, n) {
            cout << mat[i][j];
            cout << (j == n-1 ? '\n' : ' ');
        }
    }

    return 0;
}

C++: #include <stdio.h>
#define N 101

int main() {

  int n,i,k,l,j,u,a[N][N],v[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++) {
    for(j=1;j<=n;j++){
      a[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    while(k>0){
      scanf("%d",&l);
      a[u][l] = 1;
      k--;
    }
  }

  for(i=1;i<=n;i++) {
    for(j=1;j<=n;j++){
      if(j == n) {
	printf("%d",a[i][j]);
      }else{
	printf("%d ",a[i][j]);
      }
    }
    printf("\n");
  }

  
  return 0;
}