Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

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

int main()
{
    int n;
    cin >> n;
    int adjacency_matrices[n][n];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            adjacency_matrices[i][j] = 0;
    int vertex;
    int degree;
    for(int i = 0; i < n; i++)
    {
        cin >> vertex;
        cin >> degree;
        int to_v;
        for(int j = 0; j < degree; j++)
        {
            cin >> to_v;
            adjacency_matrices[vertex - 1][to_v - 1] = 1;
        }
    }

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

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

int a[101][101] = {0}; //???????????????u??¨u?????£??\?????????????????????v  u??????v???????????£???????????°1

int main() {
  int n;
  cin >> n;

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

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      cout << a[i][j];

      cout << " ";
    }
    cout <<  endl;
  }
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int i;
  int a[150][150];
  int x,y;
  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      a[x][y]=0;
    }
  }

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

  }

  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      printf("%d ",a[x][y]);
    }printf("?\n");
  }

  return 0;
}

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

using namespace std;

static const int N = 100;

int main()
{
    int M[N][N];

    int num, vertexId, numOfEdge, targetVertex;

    scanf("%d", &num);

    for (int i = 0; i < num; i++) {
        for (int j = 0; j < num; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < num; i++) {
        scanf("%d %d", &vertexId, &numOfEdge);
        vertexId--; //change to idx
        for (int j = 0; j < numOfEdge; j++) {
            scanf("%d", &targetVertex);
            targetVertex--;
            M[vertexId][targetVertex] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                if(vec[i][k]==j) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  bool graph[n][n] ;

  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) graph[i][j] = false;

  int v,k,v1;
  for(int i = 0; i < n; i++){
    cin >> v >> k;
    v--; //0index
    for(int j = 0; j < k; j++){
      cin >> v1;
      v1 --; //0index
      graph[v][v1] = true;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(graph[i][j]) cout << 1;
      else cout << 0 ;

      if(j == n-1) cout << endl;
      else cout << ' ';
    }
  }
  return 0;
}

C++: #include<stdio.h>
typedef struct{
  int u;
  int k;
  int v[100];
}Graph;

main(){
  int i,j,n;
  int a[100][100];
  Graph node[100];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&node[i].u);
    scanf("%d",&node[i].k);
    for(j=0;j<node[i].k;j++)scanf("%d",&node[i].v[j]);
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
    for(j=0;j<node[i].k;j++){
      a[i][node[i].v[j]-1] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j<n)printf(" ");
    }
    if(i<n)printf("\n");
  }

  return 0;
}

C++: #include <iostream>
#include <array>
#include <algorithm>

const int size = 1005;
using matrix = std::array<std::array<int, size>, size>;

int main ()
{
  int n;
  std::cin >> n;


  matrix a;
  std::for_each(a.begin(), a.end(), [](auto x){x.fill(0);});

  auto nn = n;
  while (nn != 0)
    {
      int i, k;
      std::cin >> i >> k;
      while (k != 0)
        {
          int j;
          std::cin >> j;
          a[i-1][j-1] = 1;
          --k;
        }
      --nn;
    }

  for (int i=0; i<n; ++i)
    {
      for (int j=0; j<n; ++j)
        {
          if (j) std::cout << ' ';
          std::cout << a[i][j];
        }
      std::cout << std::endl;
    }
}