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>
using namespace std;

#define MAX 100

int G[MAX + 1][MAX + 1];

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

  for ( int i = 1; i <= n; i++ ) {
    int m; cin >> m;
    int n; cin >> n;
    for ( int j = 1; j <= n; j++ ) {
      int k; cin >> k;
      G[i][k] = 1;
    }
  }

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

  return 0;
}

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

int main(){
    int num;
    cin >> num;
    bool A[num+1][num+1];
    
    for(int i=1; i<=num; i++){
        for(int j=1; j<=num; j++){
            A[j][i] = false;
        }
    }
    
    for(int i=1; i<=num; i++){
        int node;
        int n;
        cin >> node >> n;
        for(int j=1; j<=n; j++){
            int a;
            //cin >> A[i][j];
            cin >> a;
            A[node][a] = true;
            }
    }
    
    for (int i=1; i<=num; i++){
        for(int j=1; j<=num; j++){
            if(j-1!=0) {
            cout << ' ';
            }
            if(A[i][j]){
            cout << '1' ;
            }
            else{
            cout << '0';
            }
        }
        cout << endl;
    }
    
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n;
	cin >> n;
	vvi a(n, vi(n, 0));
	rep(i, n) {
		int num,m;
		cin >>num >>m;
		rep(i, m) {
			int tmp;
			cin >> tmp;
			a[num - 1][tmp - 1] = 1;
		}
	}
	rep(i, n) {
		rep(j, n) {
			cout << a[i][j]<<(j!=n-1?" ":"\n");
		}
	}
}

C++: #include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int g[101][101];
int main(){
  long ii,jj,kk;
  vector<int> a;

  memset(g,0,sizeof(g));
  int n;
  cin >> n;
  int v,vn,r;
  for(ii=0;ii<n;ii++){
    cin >> v;
    cin >> vn;
    for(jj=0;jj<vn;jj++){
      cin >> r;
      g[v][r] = 1;
    }
  }

  for(ii=1;ii<=n;ii++){
    for(jj=1;jj<=n;jj++){
      cout << g[ii][jj] ;
      if(jj!=n){
        cout << " ";
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
int fact(int n){
  int m;
  if (n == 0)
      return 1;
  m = fact(n - 1);    
  return n * m;       
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,u,k,node;
  cin>>n;
  vector<vector<int> > ma(n,vector<int>(n));
  rep(i,n){
      cin>>u>>k;
      rep(j,k){
	  cin>>node;
	  ma[u-1][node-1]=1;
      }
  }
  rep(i,n){
      rep(j,n){
	  cout<<ma[i][j]<<(j!=n-1 ? " " : "");
      }
      cout<<'\n';
  }
  return(0);
}

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

int main() {
	int m[100][100]={};
	int n,k,v,d;cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>d>>k;d--;
		for(int j=0;j<k;j++)
		{
			cin>>v;
			m[d][--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() {
    int num;
    cin >> num;
    vector<vector<int>> array(num, vector<int>(num, 0));
    for(int i=0; i<num; i++) {
        int index;
        int degree;
        cin >> index >> degree;
        for(int j=0; j<degree; j++) {
            int edge;
            cin >> edge;
            array.at(index-1).at(edge-1) = 1;
        }
    }

    for(int i=0; i<num; i++) {
        for(int j=0; j<num; j++) {
            if(j != 0) cout << " ";
            cout << array.at(i).at(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;
}