Go: package main

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	n := nextInt()
	v := make([][]int, n)
	for i := 0; i < n; i++ {
		u := nextInt()
		k := nextInt()
		for j := 0; j < k; j++ {
			v[u-1] = append(v[u-1], nextInt())
		}
	}

	for _, vvs := range v {
		for j := 1; j <= n; j++ {
			if j > 1 {
				fmt.Fprint(w, " ")
			}
			p := sort.SearchInts(vvs, j)
			if p < len(vvs) && vvs[p] == j {
				fmt.Fprint(w, 1)
			} else {
				fmt.Fprint(w, 0)
			}
		}
		fmt.Fprintln(w)
	}

	w.Flush()
}

C++: #include <bits/stdc++.h>
using namespace std;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int n = 100;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int m[n][n];
    int n, u, k, v;
    cin >> n;
    rep(i, n) {
        rep(j, n) { m[i][j] = 0; }
    }

    rep(i, n) {
        cin >> u >> k;
        u--;  // 0-indexに変換
        rep(j, k) {
            cin >> v;
            v--;          // 0-indexに変換
            m[u][v] = 1;  // uとvの間に辺を張る。
        }
    }
    rep(i, n) {
        rep(j, n) {
            if (j) cout << " ";
            cout << m[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include<stdio.h>
typedef struct{
  int u;
  int k;
  int v[100];
}Graph;

main(){
  int i,j,n;
  int a[100][100];
  Graph node[100];
  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
    for(j=0;j<node[i].k;j++){
      a[i][node[i].v[j]-1] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
    }
    if(i<n)printf("\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 < n;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<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 < n; 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<iostream>
#include<vector>
using namespace std;

int main(){
  vector<vector<int> > graph;
  int n;

  cin >> n;
  graph.resize(n);
  for(int i=0;i<n;i++){
    graph[i].resize(n);
    for(int j=0;j<n;j++){
      graph[i][j]=0;
    }
  }

  for(int i=0;i<n;i++){
    int idx,times;

    cin >> idx >> times;
    for(int j=0;j<times;j++){
      int path;

      cin >> path;
      graph[idx-1][path-1]=1;
    }
  }

  for(int i=0;i<n;i++){
    cout << graph[i][0];
    for(int j=1;j<n;j++){
      cout << " " << graph[i][j];
    }
    cout << endl;
  }
}

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

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

typedef struct node{
    int vertexCode;
    node* next;
}* nodeptr;

class chainTable {
private:
    // nothing :P
public:
    nodeptr head, tail;

    chainTable() : head(NULL), tail(NULL) {}

    void push(int newVC) {  //  VC = Vertex Code
        nodeptr tmp = new node();
        tmp->vertexCode = newVC;
        tmp->next = NULL;

        if (this->head == NULL) {
            this->head = this->tail = tmp;
        } else {
            this->tail = this->tail->next = tmp;
        }
    }

    bool canGoTo(int target) {
        nodeptr tmp = this->head;
        while (tmp != NULL) {
            if (tmp->vertexCode == target) return true;
            else tmp = tmp->next;
        }

        return false;
    }

//    void travel(int target) {
//        nodeptr tmp = this->head;
//        while (tmp != NULL) {
//            if (tmp->vertexCode == target) return true;
//            else cout << tmp->vertexCode;
//        }
//
//        return false;
//    }
};

int main() {
  //  freopen("in.txt", "r", stdin);

    int n, u, k, v;
    cin >> n;

    vector<chainTable> aList(n + 1);  // aList = adjacency list

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

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (aList[i].canGoTo(j)) {
                cout << "1 ";
            } else {
                cout << "0 ";
            }
        }
        cout << endl;
    }
//
//    cout << "--------------" << endl;
//    for (int i = 0; i < n; ++i) {
//        aList[i].travel();
//    }
}

C++: ///
// File:  alds1_11_a.cpp
// Author: ymiyamoto
//
// Created on Wed Oct 18 00:12:34 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

static uint32_t graph[100][100];

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    uint32_t id, k;
    cin >> id >> k;
    for (uint32_t j = 0; j < k; j++) {
      uint32_t v;
      cin >> v;
      graph[id - 1][v - 1] = 1;
    }
  }

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

  return 0;
}