Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

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

using namespace std;

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

    vector<vector<int>> g(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        --u;  // want to store graph as 0-origin

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

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

C++: #include<iostream>

#define MAX 105

int main(){
  int n,u,k;
  int adj[MAX][MAX] = {{0}};
  int A[MAX][MAX] = {{0}};
  std::cin >> n;
  for(int i=1;i<=n;i++){
    std::cin >> u >> k;
    for(int j=1;j<=k;j++){
      std::cin >> adj[u][j];
    }
    adj[u][k+1] = -1;
  }
  //std::cout << "入力\n";

  for(int i=1;i<=n;i++){
    int j=1;
    while(adj[i][j] != -1){
      A[i][adj[i][j]] = 1;
      j++;
    }
    std::cout << A[i][0] ;
    for(j=2;j<=n;j++){
      std::cout << ' ' << A[i][j] ;
    }
    std::cout << '\n';
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

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

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

C++: // #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;

int N = 100;

int main(){
    int m[N+1][N+1];
    int n;
    cin >> n;
    for (int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            m[i][j] = 0;
        }
    }
    for (int i=1;i<=n;i++){
        int p,r; cin >> r >> p;
        for (int j=1;j<=p;j++){
            int q;
            cin >> q;
            m[r][q] = 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;
    }
}

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