Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

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

C++: #include<iostream>
#include <cstdlib>
#include<list>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<stack>
#define MAX 101
using namespace std;
int main() {
	int n, a, k, d, data[MAX][MAX] = { 0,0 }; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> d;
			data[i][d - 1] = 1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (j)cout << " ";
			cout << data[i][j];
		}
		cout << endl;
	}
	return 0;
}