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>
#include <vector>

namespace
{
void OutputRow(int Length, std::vector<int>::const_iterator Begin, std::vector<int>::const_iterator End)
{
	std::vector<int>::const_iterator It = Begin;
	for(int i = 1; i < Length; ++i){
		if(It == End || i < *It){
			std::cout << 0;
		}else{
			std::cout << 1;
			++It;
		}
		
		if(i < Length - 1){
			std::cout << " ";
		}else{
			std::cout << std::endl;
		}
	}
}
}//unnamed namespace
//================================================================

class TGraph
{
	std::vector<std::vector<int> > FNodes;
public:
	TGraph(int Count);
	
	void InputNodes(int Index, int BranchCount);
	void OutputAdjacencyMatrix()const;
};

TGraph::TGraph(int Count)
:FNodes(Count + 1)
{
}

void TGraph::InputNodes(int Index, int BranchCount)
{
	for(int i = 0; i < BranchCount; ++i){
		int Target;
		std::cin >> Target;
		FNodes[Index].push_back(Target);
	}
}

void TGraph::OutputAdjacencyMatrix()const
{
	for(unsigned int i = 1; i < FNodes.size(); ++i){
		OutputRow(FNodes.size(), FNodes[i].begin(), FNodes[i].end());
	}
}
//================================================================

int main()
{
	int Count;
	std::cin >> Count;
	TGraph Graph(Count);
	for(int i = 0; i < Count; ++i){
		int Index;
		std::cin >> Index;
		int BranchCount;
		std::cin >> BranchCount;
		Graph.InputNodes(Index, BranchCount);
	}
	Graph.OutputAdjacencyMatrix();
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <vector>
using namespace std;

int n;
int G[100][100];

void init() {
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            G[i][j] = 0;
        }
    }
}

void makeAdjMatrix() {
    int u, k, to;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> to;
            G[u - 1][to - 1] = 1;
        }
    }
}

void print() {
    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] << " ";
            }
        }
        cout << endl;
    }
}

int main() {
    init();
    cin >> n;
    makeAdjMatrix();
    print();
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define N_MAX 100

typedef struct _v {
    int k;
    struct _v *v;
} Vertex;
Vertex Adj[N_MAX];
int M[N_MAX][N_MAX];


int main() {
    int n;

    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
        int k;
        cin >> k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int l;
            cin >> l;
            M[i][l-1] = 1;
//            printf("M[%d][%d] = %d\n", i, l-1, M[i][l-1]);
        }
    }

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


    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define CLR(a)     memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)    cerr << #x << " = " << (x) << endl;//debug
#define debug(x)   cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define EPS        1e-10//sample:if((double)>=(double)+EPS)
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;



int main(){
  int n;
  cin>>n;
  int a[100][100]={};
  int s,t,u;
  //int maxs=INT_MIN,maxu=INT_MIN;
  rep(i,n){
    cin>>s>>t;
    rep(j,t){
      cin>>u;
      a[s][u]=1;
      //u=max(maxu,u);
    }
    //s=max(maxs,s);
  }
  //int maxn=max(maxs,maxu);
  
  rep(i,n){
    rep(j,n){
      cout<<a[i+1][j+1];
      if(j!=n-1)cout<<" ";
    }cout<<endl;
  }
  

  return 0;
}

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

int main(){
  int n,u,k,v;
  int i,j;
  int A[MAX][MAX];
  cin >> n;
  for(i = 0; i < n; i++){
    for(j = 0; j< n; j++){
      A[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    cin >> u;
    cin >> k;
    u = u-1;
    for(j = 0; j < k; j++){
      cin >> v;
      v = v-1;
      A[u][v] = 1;
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(0 < j){
        cout << " ";
      }
      cout << A[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class Graph
{
public:
  int solve();
};

int Graph::solve()
{
  int n;
  cin >> n;
  
  vector<vector<int>> adj( n + 1, vector<int>( n + 1, 0 ) );
  
  for ( auto i = 0; i < n; ++i )
    {
      int u;
      int k;
      int v;
      cin >> u;
      cin >> k;
      for ( auto j = 0; j < k; ++j )
        {
          cin >> v;
          adj[u][v] = 1;
        }
    }

  for ( auto i = 1; i <= n; ++i )
    {
      for ( auto j = 1; j <= n; ++j )
        {
          if ( j > 1 ) cout << " ";
          cout << adj[i][j];
        }
      cout << endl;
    }
  
  return 0;
}

int main()
{
  Graph g;

  g.solve();

  return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> mat(n,vector<ll>(n,0));
    for(ll i=0;i<n;i++) {
        ll u,k;
        cin>>u>>k;
        for(ll j=0;j<k;j++) {
            ll tmp;
            cin>>tmp;
            mat[u-1][tmp-1] = 1;
        }
    }
    for(ll i=0;i<n;i++) {
        for(ll j=0;j<n;j++) {
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }
}

C++: #include<iostream>
using namespace std;
int a[105][105];

int main ()
{
	int n, u, k, temp;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> u >> k;
		u--;
		for(int j = 0; j < k; j++)
		{
			cin >> temp;
			temp--;
			a[u][temp] = 1;
		}
	}
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cout << a[i][j] << " "; 
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	int graph[100][100] = {};
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int now,m;
		cin >> now >> m;
		for(int j = 0;j < m;j++) {
			int t;
			cin >> t;
			graph[now - 1][t - 1] = 1;
		}
	}
	for(int i = 0;i < n;i++){
		cout << graph[i][0];
		for(int j = 1;j < n;j++){
			cout << " " << graph[i][j];
		}
		cout << endl;
	}
	return 0;
}