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++: // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    Graph G(N, vector<int>(N, 0));
    rep(i, N){
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, k){
            int v;
            cin >> v;
            v--;
            G[u][v] = 1;
        }
    }

    rep(i, N){
        rep(j, N){
            if(j) cout << ' ';
            cout << G[i][j];
        }
        cout << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main() {
  int n,p,q,r;
  cin>>n;
  int a[100][100]={};
  for (int i=0;i<n;i++){
    cin>>q>>p;
    if (p!=0){
      for (int j=0;j<p;j++){
	cin>>r;
	a[i][r-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 <stdio.h>

#define N 100

int main(){
	int n;
	scanf("%d",&n);
	int A[N][N];
	int i;
	int v;
	int j;
	int p;
	int q;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			A[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		scanf("%d",&v);
		scanf("%d",&q);
		for(j=0;j<q;j++){
			scanf("%d",&p);
			A[v-1][p-1] = 1;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n-1;j++){
			printf("%d ",A[i][j]);
		}
		printf("%d\n",A[i][j]);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

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

using namespace std;

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix);

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

    string line;
    getline(cin, line); // skip first newline character

    vector<vector<int> > vertex(n, vector<int>(n, -1));
    for (int i = 0; i < n; ++i) {
        getline(cin, line);

        string tmp;
        stringstream ss(line);
        int j = 0;
        while (getline(ss, tmp, ' ')) {
            if (j == 0) {
                ++j;
                continue;
            }

            vertex[i][j - 1] = stoi(tmp);
            ++j;
        }
    }

    vector<vector<int> > adjacent(n, vector<int>(n, 0));
    to_adjacent_matrix(vertex, adjacent);

    for (int i = 0; i < n; ++i) {
        cout << adjacent[i][0];
        for (int j = 1; j < n; ++j)
            cout << ' ' << adjacent[i][j];
        cout << '\n';
    }
}

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix)
{
    int n = adjacent_list.size();

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n && adjacent_list[i][j] != -1; ++j) {
            int adjacent = adjacent_list[i][j] - 1;
            if (adjacent <= 0 || adjacent > n)
                continue;

            adjacent_matrix[i][adjacent] = 1;
        }
    }
}

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

int main(){
  int n, u, k, v;
  cin >> n;
  int A[n * n] = {0};

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    while(k--){
      cin >> v;
      A[(u - 1) * n + (v - 1)] = true;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(j) cout << " ";
      cout << A[i * n + j];
    }
    cout << endl;
  }
}

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

using namespace std;

const int edge = 1;
const int no_edge = 0;

int main() {
  int vertex_num;
  cin >> vertex_num;

  // init
  vector<vector<int>> list_graph(
    vertex_num,
    vector<int>(vertex_num, 0)
  );

  // convert
  for(int i = 0; i < vertex_num; i++) {
    int vertex_label;
    int adjacency_vertex_num;
    cin >> vertex_label >> adjacency_vertex_num;

    for(int j = 0; j < adjacency_vertex_num; j++) {
      int adjacency_vertex_label;
      cin >> adjacency_vertex_label;

      list_graph[vertex_label - 1][adjacency_vertex_label - 1] = edge;
    }
  }


  // print
  for(int i = 0; i < vertex_num; i++) {
    for(int j = 0; j < vertex_num; j++) {
      cout << list_graph[i][j];

      if(j != vertex_num - 1) {
        cout << ' ';
      }
    }
    cout << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int> > mat(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        int u,k;
        cin >> u >> k;
        for(int j=0;j<k;j++){
            int v;
            cin >> v;
            mat.at(u-1).at(v-1)=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << mat.at(i).at(j);
            if(j==n-1) cout << endl;
            else cout << " ";
        }
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef vector<vector<int>> matrix;

int main()
{
    // 入力
    int N;
    cin >> N;
    matrix G(N + 1, vector<int>(N + 1, 0));

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

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