Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

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

int main()
{
  int n;
  cin>>n;
  int list[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      list[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    int u,k,to;
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>to;
      to--;
      for(int l=0;l<n;l++){
	if(l==to){
	  list[u][l]=1;
	}else{
	}
      }
    }
  }
  //print
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<list[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}

C++: 
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    int ans[n+1][n+1] = {0};
    for(int i = 0; i < n; i++){
        int index, k;
        cin >> index >> k;
        for(int j = 0; j < k; j++){
            int jndex;
            cin >> jndex;
            ans[index][jndex] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n; j++){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][n];
        cout << endl;
    }
    //cout << masu << endl;
    return 0;
}

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