Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
#define MAX 500000
#define SENTINEL 2000000000
#define NIL -1
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
static const ll N =100;
int main(){
    ll Adj[N][N];
    ll n,u,k,v;
    cin >> n;
    REP(i,n)REP(j,n)Adj[i][j]=0;

    REP(i,n){
        cin >> u >> k;
        u--;
        REP(j,k){
            cin >> v;
            v--;
            Adj[u][v] =1;
        }
    }
    REP(i,n){
        REP(j,n){
        if(j)cout << " ";
        cout<<Adj[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

int main() {
    int n, u, k, v;
    cin >> n;

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

    REP(i, n) {
        cin >> u >> k;
        u--;
        REP(j, k) {
            cin >> v;
            v--;
            mat[u][v] = 1;
        }
    }

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

C++: #include <stdio.h>
#define MAX_N (105)

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

    for ( int i = 1; i <= n; i++ ) {
	for ( int j = 1; j <= n; j++ ) {
	    printf("%d%c", G[i][j], ( j==n ) ? '\n' : ' ');
	}
    }
    
    return 0;
}

C++: #include<iostream>

using namespace std;

#define MAX 100

int A[MAX][MAX];

int main(int argc, char const *argv[])
{
	int n,k,m,p;
	cin>>n;

	for (int i = 0; i < n; ++i)
	{
		cin>>k>>m;
		for (int j = 0; j < m; ++j)
		{
			cin>>p;
			A[k-1][p-1]=1;
		}
	}

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

	return 0;
}

C++: #include <iostream>
using namespace std;
static const int N = 100;

int main()
{
    int M[N][N];
    int n, u, k, v;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            M[i][j] = 0;
        }
    }

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

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

C++: #include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)

using namespace std;
typedef long long ll;
const int NMAX = 100;
const int k = 200000;
static const int INF = 1<<29;
string s,t,ans;
int dp[3001][3001];
ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}
int M[NMAX+1][NMAX+1]={0};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
    // 追加２, 以降 cin の入力元が 'input.txt' になる

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

C++: #include<iostream>
int main(){
    int n;
    std::cin>>n;
    int A[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    int tmp,s,e;
    for(int i=0;i<n;i++){
        std::cin>>s;
        std::cin>>tmp;
        for(int j=0;j<tmp;j++){
            std::cin>>e;
            A[s-1][e-1]=1;
        }
    }

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

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                
                if(vec[i][k]==j) {
                    if(j!=n){
                        cout << 1 <<" "; hantei=1;
                    }else{
                        cout << 1 ;
                    }    
                }
            }
            if(hantei==0){ 
                if(i!=n){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            };
        }cout << endl;
    }
}