Go: package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    ll mat[N][N];
    FOR(i, 0, N){
        FOR(j, 0, N){
            mat[i][j] = 0;
        }
    }

    FOR(i, 0, N){
        ll u; cin >> u; u--;
        ll k; cin >> k;
        FOR(j, 0, k){
            ll to; cin >> to; to--;
            mat[i][to] = 1;
            // mat[to][i] = 1;
        }
    }
    
    FOR(y, 0, N){
        FOR(x, 0, N){
            if(x) cout << ' ';
            cout << mat[y][x];
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
    int n, k, u, v;
    int G[100][100];
    cin >> 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;
        u--;
        for (int j=0; j<k; j++) {
            cin >> v;
            v--;
            G[u][v] = 1;
        }
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if ( j ) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<vector<int>> a(n, vector<int>(n,0));
	rep(i,n){
		int from;
		int m;
		cin >> from >> m;
		from--;
		rep(j,m){
			int to;
			cin >> to;
			to--;
			a[from][to] = 1;
		}
	}

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

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

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;
int edge[103][103];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;
	REP(i,n){
		int v,t;cin>>v>>t;
		v--;
		while(t--){
			int u;
			cin>>u;
			u--;
			edge[v][u] = 1;
		}
	}
	REP(i,n){
		REP(j,n){
		if(j)cout << ' ';
			cout << edge[i][j];
		}
		cout << endl;
	}
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>

int main(){
    int n;
    std::cin >> n;
    int list[n][n] = {};
    std::vector<std::vector<int>> vertex;
    int tmp2;
    int num;
    for(int i=0;i<n;i++){
        std::vector<int> tmp;
        std::cin >> tmp2;
        std::cin >> num;
        for(int j=0;j<num;j++){
            std::cin >> tmp2;
            tmp.push_back(tmp2);
        }
        vertex.push_back(tmp);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<vertex[i].size();j++){
            if(vertex[i][j] > 0){
                list[i][vertex[i][j]-1] = 1;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            std::cout << list[i][j];
            if(j!=n-1){
                std::cout << " ";
            }
        }
        std::cout << "\n";
    }
}

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

int main()
{
	int n, A[100][100];
	cin>>n;


	for(int i=0;i<n;++i){

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

		int m,k; //k=number of adj
		cin>>m>>k;
		assert(m==i+1);

		for(int j=0;j<k;++j){
			int adj;
			cin>>adj;
			if(adj){
				A[i][adj-1]=1;
			}
		}
	
		for(int j=0;j<n;++j){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}

	return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<bool>> adjacent(n, vector<bool>(n,false));

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			adjacent[u-1][v - 1] = true;
		}
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << adjacent[i][j] << (j == n-1 ? "\n" : " ");
		}
	}

}

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

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

  vector<int> c(n);
  vector<vector<int>> M(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    int node;
    int d;
    cin >> node >> d;
    node--;

    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      M[i][tmp] = 1;
    }
  }

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

C++: #include <iostream>

using namespace std;

int main(){

  int n,u,k,v,graph[101][101]={{}};

  cin >> n ;

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

  for(int i = 1; i<= u; i++){
    for(int j = 1; j<= u; j++){
      cout << graph[i][j] << ' ' ; 
    }
    cout << endl;
  }


  return 0;
}

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

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

  //vector<vector<int>> data(N, vector<int>(N));
  int data[120][120];
  for(int j=0;j<N;j++){
  int u,k;
  cin>>u>>k;
  for(int i=0;i<k;i++){
    int v;
    cin>>v;
    data[u-1][v-1]=1;
  }

}

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


  }