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++: //
//  main.cpp
//  graph
//
//  Created by ???????????? on 2017/10/22.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, i, j, id, num, node;
    scanf("%d", &n);
    int A[n][n];
    
    //initialize with 0
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            A[i][j] = 0;
        }
    }
    
    for (i = 0; i < n; i++){
        scanf("%d", &id);
        scanf("%d", &num);
        for(j = 0; j < num; j++){
            scanf("%d", &node);
            A[id-1][node-1] = 1;
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            if(i) cout << " ";
            cout<<A[i][j];
        }
        cout<<endl;
    }
    
//    std::cout << "Hello, World!\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, i, j;

	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;
		u--;
		for ( j = 0; j < k; j++ ) {
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

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

	return 0;
}

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

int main()
{
	int n, k, u, v;
	cin >> n;
	// N * N matrix filled with 0
	vector< vector<int> > mat(n, vector<int>(n, 0));

	for(int i=0; i<n; i++){
		cin >> u >> k;
		// adjust 0 origen
		u--;
		for(int j=0; j<k; j++){
			cin >> v;
			//cout << "vertex: " << v << '\n';
			// adjust 0 origen
			v--;
			mat[u][v] += 1;
		}
		//cout << '\n';
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			printf("%d ", mat[i][j]);
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int a[101][101] = {}; //???????????????u??¨u?????£??\?????????????????????v  u??????v???????????£???????????°1
  int n;
  cin >> n;

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

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      cout << a[i][j];

      if(j != n) cout << " ";
    }
    cout <<  endl;
  }
  return 0;
}

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)
#define REP(i, first, to) for(ll i = first; i <= to; ++i)

using namespace std;
typedef long long ll;

list<int> from[101];
int to[101][101];
int n;
void solve() {
	cin >> n;
	rep(i, 0, n) {
		int u, k;
		cin >> u >> k;
		rep(j, 0, k) {
			int value;
			cin >> value;
			from[u].push_back(value);
		}
	}
	REP(i, 1, n) {
		while(!from[i].empty()) {
			to[i][from[i].front()] = 1;
			from[i].pop_front();
		}
	}
	REP(i, 1, n) {
		REP(j, 1, n) {
			if (j == n) {
				cout << to[i][j] << endl;
			} else {
				cout << to[i][j] << " ";
			}
		}
	}
}

int main() {
	solve();
	return 0;
}

C++: #include <cstdio>
#define N 100
int main(){
    int M[N][N];
    int n,u,k,v;
    scanf("%d\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++){
   scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
       scanf("%d",&v);
        v--;
        M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(j)printf(" ");
       printf("%d",M[i][j]);
    }
   printf("\n");
  }
  return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int n;
typedef vector<vector<int> > AdjMatrix;
AdjMatrix graph;


int main()
{
    int u,k,v;
    cin >> n;
    graph = AdjMatrix(n, vector<int>(n, 0));
    REP(i,n){
        cin >> u >> k;
        REP(j,k){
            cin >> v;
            graph[u-1][v-1] = 1;
        }
    }


    REP(i, n){
        REP(j, n){
            cout << graph[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

int main()
{
	int n;
	int v[100][100];

	cin >> n;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			v[i][j] = 0;

	for (int i = 0; i < n; i++) {
		int u, k, t;

		cin >> u >> k;

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

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

	return 0;
}

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

struct Edge {
  int source, target;
  Edge(int source, int target): source(source), target(target) {}
};

struct Node {
  std::vector<Edge> edges;
  void addEdge(Edge edge) {
    edges.push_back(edge);
  }
};

class Graph {
private:
  std::vector<Node> nodes;
  int size;
public:
  Graph(int size): size(size) {
    nodes.resize(size);
  }
  void addEdge(int source, int target) {
    nodes[source].addEdge(Edge(source, target));
  }
  void printAdjacencyList() {
    for(Node node: nodes) {
      std::vector<int> hasEdgeTo(size);
      for(Edge edge: node.edges) {
        hasEdgeTo[edge.target] = 1;
      }
      for(auto i: hasEdgeTo) {
        std::cout << i << ' ';
      }
      std::cout << std::endl;
    }
  }
};

int main() {
  int n;
  std::cin >> n;
  Graph graph(n);
  for(int i = 0; i < n; i++) {
    int u, k;
    std::cin >> u >> k;
    for(int j = 0; j < k; j++) {
      int v;
      std::cin >> v;
      graph.addEdge(u - 1, v - 1);
    }
  }
  graph.printAdjacencyList();
}