Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

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

int main() {

    int n , u , k , s;
    cin>> n ;
    vector<vector<int> > v(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int r=0;r<k;r++){
        cin >> s;
        v[u-1][s-1] = 1;

    }
    }
    for(int i=0;i<n;i++){

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

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

int main() {
  int M[N][N];  // 0 オリジンの配列
  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;

  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    u--;  // 0 オリジンへ変換
    for ( int j = 0; j < n; j++ ) {
      cin >> v;
      v--;  // 0 オリジンへ変換
      M[u][v] = 1;  // u と v の間に辺を張る
    }
  }

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

  return 0;
}

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