Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

#include<string>
#include<cmath>
#include<map>
#include<cstdlib>
#include<deque>
#include<queue>
#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j] << " ";
    }
    cout << endl;
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}

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

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

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

int main(){
	
	int n;
	cin >> n;
	vector<vector<int>> ans(n,vector<int>(4,0));

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

	cout << "test" << endl;

	rep(i,n){
		rep(j,n-1){
			cout << ans[i][j];	
		}
		cout << ans[i][n-1] << endl;
	}

	return 0;
}

C++: #include<iostream>
int main(){
  int n,d,num;
  std::cin>>n;
  int flag,B[100][100]={0};
  for(int i=0;i<n;i++){
    std::cin>>num>>d;
    for(int j=0;j<d;j++){
      std::cin>>flag;
      B[num-1][flag-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j!=n-1){
	std::cout<<B[i][j]<<" ";
      }else{
	std::cout<<B[i][j]<<"\n";
      }
    }
  }
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>
#include <cassert>

using namespace std;
constexpr long long MOD = 1e9 + 7;
const double PI = acos(-1);

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

    int num_cities;
    cin >> num_cities;

    vector<vector<int>> graph(num_cities, vector<int>(num_cities, 0));

    int from, to, num_edges;
    for (int i = 0; i < num_cities; i++) {
        cin >> from >> num_edges;
        for (int j = 0; j < num_edges; j++) {
            cin >> to;
            graph[from - 1][to - 1] = 1;
        }
    }

    for (int i = 0; i < num_cities; i++) {
        for (int j = 0; j < num_cities; j++) {
            if (j != 0) cout << ' ';
            cout << graph[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


int n;
int g[110][110];

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

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

	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <bitset>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int N,M,num1,num2;
    bool data[101][101]={};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>num1;
        cin>>M;
        for(int j=0;j<M;j++){
            cin>>num2;
            data[num1][num2]=true;
        }
    }
    for(int i=1;i<=N;i++){
        cout<<data[i][1];
        for(int j=2;j<=N;j++){
            cout<<' '<<data[i][j];
        }
        cout<<endl;
    }
}