Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			fmt.Printf(" %d", Adj[i][j])
			if j == n-1 {
				fmt.Println()
			}
		}
	}
}

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

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