Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

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";
      }
    }
  }
}

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;
}