Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	adj := make([][]string, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]string, n)
		for j := 0; j < n; j++ {
			adj[i][j] = "0"
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		sc.Scan()
		adjList := strings.Split(sc.Text(), " ")
		outDegree, _ := strconv.Atoi(adjList[1])

		if outDegree > 0 {
			for k := 0; k < outDegree; k++ {
				j, _ := strconv.Atoi(adjList[k+2])
				adj[i][j-1] = "1"
			}
		}
	}

	for i := 0; i < len(adj); i++ {
		fmt.Println(strings.Join(adj[i], " "))
	}

}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, k[102], v[101][102] = {0}, i, j, l, a;

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

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (k[i] == 0) {
        for (l = v[i][j - 1]; l < n - 1; l++) {
          printf("0 ");
        }
        printf("0\n");
        break;
      }
      else {
        if (v[i][j] != 0) {
          k[i]--;
          for (l = v[i][j - 1]; l < v[i][j] - 1; l++) {
            printf("0 ");
          }
          if (v[i][j] == n) {
            printf("1\n");
            break;
          }
          else {
            printf("1 ");
          }
        }
      }
    }
  }

  return 0;
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
	int n;
	scanf("%d",&n);

	int** gmtrx = new int*[n];
	for(int i=0; i<n; ++i){
		gmtrx[i] = new int[n];
		for(int j=0; j<n; ++j){
			gmtrx[i][j] = 0;
		}
	}

	for(int i=0; i<n; ++i){
		int v, num, a;
		scanf("%d %d",&v,&num);
		for(int j=0; j<num; ++j){
			scanf("%d",&a);
			gmtrx[v-1][a-1] = 1;
		}

	}

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

	for(int i=0; i<n; ++i){
		delete[] gmtrx[i];
	}
	delete[] gmtrx;

	return 0;
}

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