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;

int n;
int ad_list[101][101];

void print(){
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            cout << ad_list[i][j];
            if(j==n)cout << "\n";
            else cout << " ";
        }
    }
}

int main(){
    cin  >> n;
    for(int i=1;i<n+1; i++){
        for(int j=1; j<n+1; j++){
            ad_list[i][j]=0;
        }
    }
    int v,k, in;
    for(int i=1; i<n+1; i++){
        cin >> v >> k;
        for (int j=0;j<k;j++){
            cin >> in;
            ad_list[v][in]=1;
        }
    }
    print();
}

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<bits/stdc++.h>
using namespace std;
const int MAXN = 100+7;
struct node{
    int id;
    struct node* next;
};
struct node* graph[MAXN];
int matrix[MAXN][MAXN];
int main() {
    int n;
    scanf("%d", &n);
    int i;
    for(i = 1; i <= n; i++){
        graph[i] = (node*)malloc(sizeof(node));
        graph[i]->next = NULL;
    }
    memset(matrix, 0, sizeof(matrix));
    for(i = 0; i < n; i++){
        int pnum;
        int k;
        scanf("%d", &pnum);
        scanf("%d", &k);

        int j;
        for(j = 0; j < k; j++){
            int r;
            scanf("%d", &r);
            node* newp = (node*)malloc(sizeof(node));
            newp->id = r;
            newp->next = NULL;
            node* p = graph[pnum];
            while(p->next!=NULL){
                p = p ->next;
            }
            p->next = newp;
        }
    }
    for(i = 1; i <= n; i++){
        struct node* p = graph[i]->next;
        while(p!=NULL){
            matrix[i][p->id] = 1;
            p = p->next;
        }
    }
    for(i = 1; i <= n; i++){
        int j;
        for(j = 1; j <= n; j++){
            if(j!=1) printf(" ");
            printf("%d", matrix[i][j]);
        }
        printf("\n");
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {

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

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

  return 0;
}

// EOF

C++: #include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;;
using vvi=vector<vi>;
using vb=vector<bool>;
using pii=pair<int,int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vector<vb> matr(n,vb(n,false));
    rep(i,0,n){
        int index;
        cin>>index;
        index--;
        int num,in;
        cin>>num;
        rep(c,0,num){
            cin>>in;
            in--;
            matr[index][in]=true;
        }
    }
    rep(i,0,n){
        int cnt=0;
        rep(j,0,n){
            if(cnt++)cout<<" ";
            cout<<matr[i][j];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>

int main() {
    int node_num(0);
    std::cin >> node_num;

    /* Generate Empty Matrix */
    int** graph(nullptr);
    graph = new int*[node_num];
    for (int i(0); i < node_num; ++i) {
        graph[i] = new int[node_num];
        for(int j(0); j < node_num; ++j) {
            graph[i][j] = 0;
        }
    }

    /* Input and Modify Matrix*/
    for(int i(0); i < node_num; ++i) {
        int node_index(0);
        int node_degree(0);
        std::cin >> node_index >> node_degree;
        for(int j(0); j < node_degree; ++j) {
            int tmp(0);
            std::cin >> tmp;
            graph[node_index-1][tmp-1] = 1;
        }
    }

    /* Output 隣接行列 */
    for(int i(0); i < node_num; ++i) {
        for(int j(0); j < node_num; ++j) {
            if(j != 0) {
                std::cout << " ";
            }
            std::cout << graph[i][j];
        }
        std::cout << "\n";
    }

    for(int i(0); i < node_num; ++i ){
        delete graph[i];
    }

    delete graph;

    return 0;
}