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>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using NumNode = short;
using List = std::vector<NumNode>;
struct Node {
    NumNode idx;
    NumNode value;
    List list;
};
using Nodes = std::vector<Node>;
using Edge = bool;
using Row = std::vector<Edge>;
using Array = std::vector<Row>;

Nodes input_nodes(NumNode n_node);
List make_val2idx(Nodes nodes);
Array solve(Nodes nodes);
void print_graph_array(Array array);

int main() {
    NumNode n;
    std::cin >> n;
    Nodes nodes = input_nodes(n);
    const Array array = solve(nodes);
    print_graph_array(array);
}

Nodes input_nodes(NumNode n_node) {
    Nodes nodes{};
    for (NumNode i = 0; i < n_node; ++i) {
        NumNode u, k;
        std::cin >> u >> k;

        Node node{};
        node.idx = i;
        node.value = u;

        List list{};
        for (NumNode j = 0; j < k; ++j) {
            NumNode v;
            std::cin >> v;
            list.push_back(v);
        }
        node.list = list;
        nodes.push_back(node);
    }
    return nodes;
}

Array solve(Nodes nodes) {
    Array array{};
    List val2idx = make_val2idx(nodes);
    for (Node node : nodes) {
        Row row{};
        row.resize(nodes.size());
        for (NumNode node_dst : node.list) {
            const NumNode node_dst_idx = val2idx.at(node_dst);
            row.at(node_dst_idx) = true;
        }
        array.push_back(row);
    }
    return array;
}

List make_val2idx(Nodes nodes) {
    List val2idx{};
    NumNode value_max = std::numeric_limits<NumNode>::max();
    val2idx.resize(value_max);
    for (Node node : nodes) val2idx[node.value] = node.idx;
    return val2idx;
}

void print_graph_array(Array array) {
    for (Row row : array) {
        for (auto iter_edge = row.begin(); iter_edge != row.end();
             ++iter_edge) {
            std::cout << *iter_edge;
            if (iter_edge != end(row) - 1) std::cout << ' ';
        }
        std::cout << std::endl;
    }
}

C++: #include <stdio.h>

int main(){
    int Map[101][101];
    int N, u, k, temp;
    scanf("%d\n",&N);
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++)
            Map[ix][jx] = 0;
    for (int ix = 0; ix < N; ix++){
        scanf("%d %d",&u,&k);
        for (int kx = 0; kx < k; kx++){
            scanf("%d",&temp);
            Map[u-1][temp-1] = 1;
        }
    }
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++){
            if (jx == N-1) printf("%d\n",Map[ix][jx]);
            else printf("%d ",Map[ix][jx]);
        }
    return 0;
}

C++: #include <iostream>
#include <set>
using namespace std;
static const int N = 100;

int n;

set<int> G[100];

int main(int argc, char const *argv[])
{
    int k, u, g;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> k >> u;
        for (int j = 0; j < u; j++) {
            cin >> g;
            G[i].insert(g);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (!G[i].empty()) {
                cout << ((j==0) ? "" : " ");
                cout << ((G[i].find(j+1) != G[i].end()) ? "1" : "0");
            } else {
                cout << ((j==0) ? "" : " ");
                cout << "0";
            }
        }
        cout << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
        int n, m, k, r;
        cin>>n;
        int a[n][n];
        for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                        a[i][j] = 0;
        for(int i=0;i<n;i++){
                cin>>r;
                cin>>m;
                for(int j=0;j<m;j++){
                        cin>>k;
                        a[r-1][k-1] = 1;
                }
        }
        for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                        cout<<a[i][j];
                        if(j<n-1) cout<<" ";
                        else cout<<endl;
                }
        }
        return 0;
}

C++: #include <stdio.h>

#define N 100

int main() {

  int m[N][N];
  int i, j, n, u, k, v;

  scanf("%d", &n);

  for( i=0; i<n; i++ ) {
    for( j=0; j<n; j++ ) {
      m[i][j] = 0;
    }
  }

  for( i=0; i<n; i++ ) {
    scanf("%d %d", &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) {
	printf(" ");
      }
      printf("%d", m[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

int main(){
    int M[100][100];
    int n,u,k,v;
    
    cin >> n;//頂点数
    
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            M[i][j]=0;
            //cout << M[i][j] << " ";
        }
        //cout << endl;
    }
    //cout << endl;
    
    for (int i=0; i<n; i++){
        cin >> u >> k; //uは頂点番号, kはuの出次数
        u--;
        for (int j=0; j<k; j++){
            cin >> v;//uに隣接する頂点番号
            v--;
            M[u][v]=1;
        }
        
    }
    
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            if(j==n-1) cout << M[i][j];
            else cout << M[i][j] << " ";
        }
        cout << endl;
    }
}

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

int n;
int M[101][101];
int main() {
    cin >> n;

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

    for (int l = 1; l <= n; ++l) {
        for (int i = 1; i <= n; ++i) {
            cout << M[l][i] << " ";
        }
        if (l != n)
        cout << endl;
    }

    return 0;
}

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

int main(int argc, char *argv[]) {
    int n;
    scanf("%d", &n);
    int adj_mat[n+1][n+1];

    // init
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            adj_mat[i][j] = 0;
        }
    }

    // read
    for (int i = 1; i <= n; i++) {
        int node_id, adj_num;
        scanf("%d", &node_id);
        scanf("%d", &adj_num);
        for (int j = 1; j <= adj_num; j++) {
            int adj_id;
            scanf("%d", &adj_id);
            adj_mat[node_id][adj_id] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j != n) {
                fprintf(stdout, "%d ", adj_mat[i][j]);
            } else {
                fprintf(stdout, "%d\n", adj_mat[i][j]);
            }
        }
    }

    return 0;
}

C++: #include<iostream>

int main()
{
	int n, u, k, v;
	bool filled[100][100]{};

	std::cin >> n;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> u >> k;
		u--;
		for (int j = 0; j < k; ++j)
		{
			std::cin >> v;
			filled[u][--v] = true;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (j)
				std::cout << " ";
			std::cout << static_cast<int>(filled[i][j]);
		}
		std::cout << std::endl;
	}
	return 0;
}