Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

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

int main() {
    int n, u, k, v;
    cin >> n;

    int M[n][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 != 0) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
}

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

int G[110][110] ={0};

int main(){
  int n;
  cin >> n;
  int u, k;
  int v[100000];
  for(int i=0; i<n; i++){
    cin >> u >> k;
    for(int j=0; j<k; j++){
      cin >> v[j];
      G[i][v[j]] = 1;
    }
  }
  for(int i=0; i<n; i++){
    for(int j=1; j<n; j++){
      cout << G[i][j] << " ";
    }
    cout << G[i][n] << endl;
  }
    
    
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> p;


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

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