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;

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

	static int M[101][101];
	int n;
	cin >> n;

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

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

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

using Adjacents = vector<int>;
using Vertexes = vector<Adjacents>;

int main(void) {

    int N;
    scanf("%d", &N);

    Vertexes vs;
    vs.resize(N);
    for (int i = 0, id, num; i < N; ++i) {
        scanf("%d %d", &id, &num);
        for (int j = 0, vert; j < num; ++j) {
            scanf("%d", &vert);
            vs[id-1].push_back(vert);
        }
    }

    int **matrix = new int*[N];
    for (int i = 0; i < N; ++i) {
        matrix[i] = new int[N];
        memset(matrix[i], 0, sizeof(int)*N);
        for (int j = 0; j < vs[i].size(); ++j) {
            matrix[i][vs[i][j] - 1] = 1;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            printf("%2d", matrix[i][j]);
        }
        delete[] matrix[i];
        printf("\n");
    }
    delete[] matrix;

    return 0;
}

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

int main(){
	int a[102][102] = {};
	int n,u,k,b;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> u >> k;
		for(int j = 0;j < k;j++){
			cin >> b;
			a[i][b] = 1;
		}
	}

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

	return 0;
}

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

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

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

    for (auto && row : ada_mat) {
        for (auto && elem : row) {
            std::cout << " " << elem;
        }
        std::cout << std::endl;
    }
}

C++: // J4180449 三宅亮輔
// 問題名
// - Graph
// 問題URL
// - https://onlinejudge.u-aizu.ac.jp/#/problems/ALDS1_11_A
// 所要時間
// - 20分
// 学んだこと
// 隣接行列の方が扱いやすいが
// 計算量やメモリを考えると隣接リスト表現の方が優れていると感じた
// インデックスを最初1からはじめるか0から始めるかバラバラになっていてバグを取るのに手間取った

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

typedef long long ll;

int n;

int ans[100][100];

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

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

int main(){
	int n;
	cin >> n;
	int a[100][100] = {0};
	for ( int i = 0; i < n; i++ ) {
		int u;
		cin >> u;
		int k;
		cin >> k;
		for ( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			a[u-1][v-1] = 1;
		}
	}
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			cout << a[i][j];
			if ( j < n - 1 ) cout << " ";
		}
		cout << endl;
	}
	return 0;
}

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

#define N 100

int main() {
  int i, j, n, u, k, v;
  int A[N+1][N+1];  

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

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

  
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (j > 1) cout << " ";
      cout << A[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

int main() {
   // freopen("in.txt", "r", stdin);

    int n, u, k, v;
    int graph[MAX][MAX];
    cin >> n;

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

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

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;    

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    bool graph[105][105]={false};
    int num,a,b;
    rep(i,n){
	cin>>a>>b;
	rep(j,b){
	    cin>>num;
	    graph[a][num]=true;
	}
    }
    reps(i,n){
	reps(j,n-1){
	    cout<<graph[i][j]<<" ";
	}
	cout<<graph[i][n]<<'\n';
    }
    
    return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int G[n][n];
  rep(i,n) memset(G[i], 0, sizeof(G[i]));
  int u, k;
  rep(i,n) {
    cin >> u >> k;
    rep(j,k) {
      int t;
      cin >> t;
      G[i][t-1] = 1;
    }
  }

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

C++: #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector< vector<int> > g_matrix;
    g_matrix = vector< vector<int> >(n, vector<int>(n, 0));
    
    for(int i = 0; i < n; i++){
        int u, k;
        scanf("%d %d", &u, &k);
        u--;
        for(int j = 0; j < k; j++){
            int v;
            scanf("%d", &v);
            v--;
            g_matrix[u][v] = 1;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n - 1; j++){
            printf("%d ", g_matrix[i][j]);
        }
        printf("%d", g_matrix[i][n - 1]);
        printf("\n");
    }
    return 0;
}