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 <iostream>
using namespace std;

#define N 105

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

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;++i)

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> MAPPING;
    vector<int> temp;
    temp.resize(n,0);
    MAPPING.resize(n,temp);
    
    REP(i,n){
        int index;cin >> index;
        int arr_size;cin >> arr_size;
        int number;
        REP(j,arr_size){
            cin>>number;
            MAPPING[index-1][number-1]=true;
        }
    }
    REP(i,n){
        REP(j,n){
            cout << (MAPPING[i][j] ? 1 : 0);
            if(j+1!=n)cout<<" ";
        }
        cout << endl;
    }        
}

C++: // A-Graph.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。
//

#include <iostream>
#include<string>
using namespace std;
int main()
{
	int n = 0;
	cin >> n;
	int **arr = new int *[n];
	for (int i = 0; i < n; i++)
	{
		arr[i] = new int[n];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			arr[i][j] = 0;
		}
	}
	int n2 = n;
	int x = 0;
	while (n--)
	{
		cin.ignore(100, '\n');
		char *str = new char[1000];
		cin.get(str, 1000);
		int y = 4;
		for (int k = 0; k < str[2] - '0'; k++)
		{
			int pos = str[y] - '0';
			pos--;
			y = y + 2;
			arr[x][pos] = 1;
		}
		x++;
	}
	for (int i = 0; i < n2; i++)
	{
		for (int j = 0; j < n2; j++)
		{
			if (j == n2 - 1)
			{
				cout << arr[i][j];
			}
			else {
				cout << arr[i][j] << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

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

int n,m,k,l,a[100][100];

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>l>>m;
        for(int j=0;j<m;j++){
            cin>>k;
            a[l-1][k-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i][0];
        for(int j=1;j<n;j++){cout<<' '<<a[i][j];}
        cout<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

int a[110][110];

int main(){
  int n; cin >> n;
  rep(x, n){
    int i, m; cin >> i >> m;
    rep(y, m){
      int j; cin >> j;
      a[i][j] = 1;
    }
  }

  REP(i, 1, n){
    REP(j, 1, n){
      if(j != 1) 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;
    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 <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";
      }
    }
  }
}