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>
#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 <stdio.h>
 
int map_max;
int map[110][110];
int rows;
int cols[110];
int mat[110][110] = {};
 
void get_map();
void print_map();
void conv_map();
void print_mat();
 
int main()
{
 
  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}
 
void get_map()
{
 
  int k;
  scanf("%d", &map_max);//<100
 
  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
    {
      scanf("%d", &map[i][j]);
    }
    }
 
   
  return ;
}
 
void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      printf("%d", map[i][j]);
    }
      puts("");
    }
return ;
}
 
 
void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      mat[i][map[i][j]-1]=1;
    }
    }
  return ;
}
 
void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
    {
      printf("%d", mat[i][j]);
      if(j!=map_max-1)
        {
          printf(" ");
        }
    }
      if(i!=map_max-1)
    {
      printf("\n");
    }
    }
}

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

int main(){
  int n;
  cin >> n;
  int u, k, v, adj[MAX+1][MAX+1];

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

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

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

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100],v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i] >> k[i];

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<k[i]; j++){
      if(v[i][j]==j)
        cout << 1;

      else
        cout << 0;

      if(j!=k[i]-1)
        cout << " ";
      }
      cout << endl;
    }
  }

C++: #include <iostream>

using namespace std;

int main(int argc, char** argv)
{
	// Input
	int adj_m[100][100] = { 0 };
	int n;
	cin >> n;
	int u,v,k;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			adj_m[u - 1][v - 1] = 1;
		}
	}

	// Output
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j)
				cout << " ";
			cout << adj_m[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

#define M 100;

int main(){
  int n,c,t,v;

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

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

  return 0;
}

C++: #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;


int main(){
    int n;
    cin >> n;
    vector<list<int>>  L(n);
    rep(i,n){
        int u, e;
        cin >> u>>e;
        rep(j,e){
            int v;cin>>v;--v;
            L[i].push_back(v);
        }
    }
    vector<vector<int>> M(n,vector<int>(n));
    rep(i,n){
        rep(j,n){
            list<int>::iterator it = find(L[i].begin(),L[i].end(),j);
            if(it!=L[i].end()){
                M[i][j]=1;
                L[i].erase(it);
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(j) cout << " "<<M[i][j];
            else cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int graph[100][100] = {0};
	int num;
	int hon;
	int eda;
	int ver;

	cin>>num;
	for(int i=0;i<num;i++){
		cin>>eda;
		cin>>hon;
		for(int j=0;j<hon;j++){
			cin>>ver;
			graph[eda][ver]++;
		}
	}
	for(int i=1;i<=num;i++){
		for(int j=1;j<=num;j++){
			cout<<graph[i][j];
			if(j==num-1)
				break;
			cout<<" ";
		}
		cout<<endl;
	}

	return 0;
}