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>
#include <stdlib.h>

using namespace std;

class Graph{
private:

  int n;
  int **vect;

public:

  Graph(int n){
    int i;
    int j;
    this->n = n;
    vect = new int*[n];
    for(i = 0;i < n;i++){
      vect[i] = new int[n];
    }
    for(i = 0;i < n;i++){
      for(j = 0;j < n;j++){
	vect[i][j] = 0;
      }
    }
  }

  ~Graph(){
    int i;
    for(i = 0;i < n;i++){
      delete[] vect[i];
    } 
    delete[] vect;
  }

  void setVector(int i,int j){
    vect[i-1][j-1] = 1;
  }

  void printVector(){
    int i;
    int j;

    for(i = 0;i < n;i++){
      for(j = 0;j < n-1;j++){
	cout << vect[i][j] << ' ';
      }
      cout << vect[i][n-1] << endl;
    }
  }

};

int main(){

  int i;
  int j;
  int n;
  int m;
  int x;
  int y;
  Graph* graph;

  cin >> n;

  graph = new Graph(n);

  for(i = 0;i < n;i++){
    cin >> x;
    cin >> m;
    for(j = 0;j < m;j++){
      cin >> y;
      graph->setVector(x,y);
    }
  }

  graph->printVector();

  delete graph;

  return 0;
}

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

int main() {
	int n;
	cin >> n;
	queue<int> q;

	for (int i = n, k; i--;) {
		cin >> k >> k;
		for (int j = 0, v; j < k; j++) {
			cin >> v;
			q.push(v);
		}

		for (int j = 1; j <= n; j++) {
			cout << (j == 1 ? "" : " ");
			if (k && q.front() == j) {
				cout << 1; 
				q.pop();
			} else
				cout << 0;
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void printVec(vector<T>&);
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);
int ctoi(const char);  // char to int

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    int V_num;
    cin >> V_num;
    vector< vector<int> > adjacent(V_num, vector<int>(V_num, 0));

    REP(i, V_num) {
        int v_idx, deg;
        cin >> v_idx >> deg;
        REP(j, deg) {
            int edge;
            cin >> edge;
            adjacent[v_idx - 1][edge - 1] = 1;
        }
    }
    print2DVec(adjacent);
    
    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void print2DVec(vector< vector<T> >& vec) {
    int len_vec_front = vec.front().size();
    REP(i, vec.size()) {
        REP(j, len_vec_front) {
            cout << vec.at(i).at(j);
            if (j < len_vec_front - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、全てnumの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}

int ctoi(const char c) {
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

C++: #ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var)\
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

constexpr auto no_value = numeric_limits<uint64_t>::max();

int main() {
  int n;
  cin >> n;
  vector<vector<int>> edges(n, vector<int>());
  for (int i = 0; i < n; ++i) {
    int u;
    int k;
    cin >> u >> k;
    edges[u - 1].reserve(k);
    for (int j = 0; j < k; ++j) {
      int v;
      cin >> v;
      edges[u - 1].push_back(v - 1);
    }
  }

  vector<vector<int>> mat(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    for (auto&& e : edges[i]) {
      mat[i][e] = 1;
    }
  }

  for (auto it = mat.begin(); it != mat.end(); ++it) {
    bool first = true;
    for (auto it2 = it->begin(); it2 != it->end(); ++it2) {
      if (!first) {
        cout << " ";
      }
      first = false;
      cout << *it2;
    }
    cout << endl;
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int g[100][100];
int main(){
	int n;cin>>n;
	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)cout<<" "<<g[i][j];
		cout<<endl;
	}
}

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


int main() {
    int n;
    int id = 0;
    int M[MAX][MAX] = { 0 };
    
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int k = 0;
        scanf("%d %d", &id, &k);
        
        if (k == 0) continue;
        
        for (int j = 1; j <= k; j++) {
            int a = 0;
            scanf("%d", &a);
            M[i][a] = 1;
        }
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j >= 2) printf(" ");
            printf("%d", M[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}