Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

C++: #include<stdio.h>
#define N 200

int main(){
  int M[N][N];
  int n,u,k,v;

  scanf("%d",&n);

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


    }

  return 0;
  }

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