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 () {
    
    int N,n,k,x;
    
    cin >> N;
    
    int A[105][105] = {};
    
    for (int i = 1; i <= N; i ++) {
        
        cin >> n >> k;
        
        for (int j = 0; j < k; j ++) {
            
            cin >> x;
            
            A[i][x] = 1;
            
        }
        
    }
    
    for (int i = 1; i <= N; i ++) {
        
        for (int j = 1; j < N; j ++) {
            
            cout << A[i][j] << " ";
            
        }
        
        cout << A[i][N] << endl;
        
    }
    
    return 0;
    
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
vint G[100];
int AM[100][100];

int main() {

	cin >> N;
	rep(i, N){
		int id, D; 
		cin >> id >> D; id--;
		rep(j, D){
			int n; cin >> n; n--;
			G[id].push_back(n);
		}
	}

	rep(i, N) rep(j, N){
		AM[i][j] = 0;
	}
	rep(i, N){
		vint v = G[i]; 
		rep (j, v.size()){
			AM[i][v[j]] = 1;
		}
	}

	rep(i, N){
		rep(j, N){
			cout << AM[i][j];
			if (j == N - 1){ cout << "\n"; }
			else{ cout << " "; }
		}
	}
}

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

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

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

int main(){
  
  int n, u, k, v;
  bool a[110][110] = {}; //adjacency matrix

  //input
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> v;
      a[u][v] = true;
    }
  }

  //output
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      cout << (j - 1?" ":"");
      cout << a[i][j];
    }
    cout << endl;
  }
  
  return 0;
}

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

using namespace std;

//4
//1 2 2 4
//2 1 4
//3 0
//4 1 3

//0 1 0 1
//0 0 0 1
//0 0 0 0
//0 0 1 0

int main() {

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

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

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

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

	return 0;

}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#ifndef NULL
#define NULL 0
#endif
using namespace std;

int mp[110][110];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			int c;
			cin >> c;
			mp[a][c] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < n; j++)
			cout << mp[i][j] << ' ';
		cout << mp[i][n] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int matrix[200][200];
int main() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    int u, k, v; cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      matrix[u-1][v-1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << matrix[i][j];
      if (j != n-1) {
        cout << " ";
      } else {
        cout << endl;
      }
    }
  }
}

C++: //
// Created by tattsun on 2017/02/11.
//

#include <iostream>
#include <vector>
using namespace std;

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

    int u, k, p;
    for(int i=0; i<n; i++) {
        cin >> u >> k;

        vector<int> dest;
        for(int j=0; j<k; j++) {
            cin >> p;
            dest.push_back(p);
        }

        auto it = dest.begin();
        for(int j=0; j<n; j++) {
            if(j != 0) cout << " ";
            if(it != dest.end() && j == *it-1) {
                cout << "1";
                it++;
            } else {
                cout << "0";
            }
        }
        cout << endl;
    }
}

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

int main(void){
  int i,j,n,u,k,w;
  int v[N][N];
  scanf("%d",&n);

  for(i =0; i<n ;i++){
    for (j=0 ; j<n; j++){
      v[i][j]=0;
    }
  }

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

  for (i =0 ; i <n ;i++){
    for(j=0 ; j<n ; j++){
      if(j) printf(" ");
      printf("%d",v[i][j]);
    }
    printf("\n");
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int n, m, u, v, adj[105][105];
int main() {
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> u >> m;
        for (int j=0; j<m; j++) {
            cin >> v;
            adj[u][v]=1;
        }
    }
    
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            cout << adj[i][j];
            if (j!=n) cout << " "; 
        }
        cout << "\n";
    }
}

C++: //
//  main.cpp
//  graph
//
//  Created by ???????????? on 2017/10/22.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, i, j, id, num, node;
    scanf("%d", &n);
    int A[n][n];
    
    //initialize with 0
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            A[i][j] = 0;
        }
    }
    
    for (i = 0; i < n; i++){
        scanf("%d", &id);
        scanf("%d", &num);
        for(j = 0; j < num; j++){
            scanf("%d", &node);
            A[id-1][node-1] = 1;
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            if(j) cout << " ";
            cout<<A[i][j];
        }
        cout<<endl;
    }
    
//    std::cout << "Hello, World!\n";
    return 0;
}