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>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int main() {
	int point;
	cin >> point;
	vector<queue<int> >lis(point);
	for (int i = 0;i < point;i++) {
		int V,edges;
		cin >> V>>edges;
		for (int j = 0;j < edges;j++) {
			int h;
			cin >> h;
			lis[i].push(h-1);
		}
	}

	vector<vector<int> > v(point, vector<int>(point, 0));
	for (int i = 0;i < point;i++) {
		while (!lis[i].empty()) {
			int j = lis[i].front();
			lis[i].pop();
			v[i][j] = 1;
		}
	}
	for (int i = 0;i < point;i++) {
		for (int j = 0;j < point;j++) {
			if (i == point - 1 && j == point - 1) {
				cout << v[i][j];
			}
			else
			cout << v[i][j]<<" ";
		}
		cout << endl;
	}

	return 0;
	
}

int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}

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

int p[NUM];
int result[NUM][NUM];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            result[i][j] = 0;
        }
    }

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

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (j)
                cout << ' ';
            cout << result[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include <stdio.h>
int A[100][100];
int main(void){
  int k,j,n,u,v,uv,V;
  scanf("%d",&V);
  for(n=0;n<V;n++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u-1][v-1]=1;
    }
  }
  for(v=0;v<V;v++){
    
    for(uv=0;uv<V;uv++){
      if(uv!=0){
	printf(" ");
      }
      printf("%d",A[v][uv]);
    }
    printf("\n");
  }
  
  return 0;
}

C++: 
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int A[101][101];

int main() {
	int n;
	cin >> n;
	for (int t = 0; t < n; t++) {
		int i, k;
		cin >> i >> k;
		for (int s = 0; s < k; s++) {
			int j;
			cin >> j;
			A[i][j] = 1;
		}
	}
	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < n + 1; j++) {
			if (j != 1)cout << ' ';
			cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;


struct node {
    int id;
    node *next;
};


node hdrs[101];
int adj[101][101];


int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        hdrs[i].next = &hdrs[i];
        hdrs[i].id = i;
    }

    for (int i = 1; i <= n; i++) {
        int k;
        int id;
        cin >> id >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;

            node *t = (node *)malloc(sizeof(node));
            t->id = v;
            t->next = hdrs[id].next;
            hdrs[id].next = t;
        }
    }

    for (int i = 1; i <= n; i++) {
        node *t = &hdrs[i];
        while (t->next != &hdrs[i]) {
            t = t->next;
            adj[i][t->id] = 1;
        }
    }

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

    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 2147483647
 
using namespace std;

int main(void)
{
	int n, k, u, v;
	int G[101][101];

	cin >> n;

	memset(G, 0, sizeof(G));

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

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

	return (0);
}