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;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#define MAX 100

int A[MAX][MAX];


int main(){
    int n, u, k, v;
    cin >> n;

    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < MAX; j++){
            A[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        cin >> u >> k;
        u--; //0オリジンに変換
        for(int j = 0; j < k; j++){
            cin >> v;
            v--; //0オリジンに変換
            A[u][v] = 1;
        }
    }

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

    return 0;
}

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

using namespace std;

int main(void){

  int graph[100][100];
  fill( graph , graph + 100 , 0 );

  int n;
  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    int u, k;
    cin >> u >> k;
    u--;
    while( k-- ){
      int v;
      cin >> v;
      v--;
      graph[u][v] = 1;
    }
  }
  for( int i = 0 ; i < n ; i++ ){
    for( int j = 0 ; j < n ; j++ ){
      if( j == n - 1 ) cout << graph[i][j] << endl;
      else cout << graph[i][j] << " ";
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1
static const int N = 100;

int main(){
  int M[N][N];
  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<k;j++){
        cin >> v;
        v--;
      M[u][v] = 1;

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

C++: #include <iostream>

int main(){
    int vertex;
    std::cin.tie( 0 );
    std::cin >> vertex;

    bool** adjMatrix = new bool*[vertex];
    for( int i = 0; i < vertex; ++i ){
        adjMatrix[i] = new bool[vertex];
    }

    for( int i = 0; i < vertex; ++i ){
        for( int j = 0; j < vertex; ++j ){
            adjMatrix[i][j] = false;
        }
    }

    int tag;
    int degree;
    int tmp;
    for( int i = 0; i < vertex; ++i ){
        std::cin >> tag >> degree;
        while( degree-- > 0 ){
            std::cin >> tmp;
            adjMatrix[tag-1][tmp-1] = true;
        }
    }

    for( int i = 0; i < vertex; ++i ){
        for( int j = 0; j < vertex; ++j ){
            std::cout << static_cast<int>( adjMatrix[i][j] ) << ( ( j < vertex-1 )? " " : "\n" );
        }
    }

    delete[] adjMatrix;
}

C++: #include<cstdio>
#include<array>
using namespace std;
const int MAX_V = 100;
array<array<int,MAX_V>,MAX_V> ary{0};
int main(){
  int n;scanf("%d",&n);
  for(int i=0;i<n;i++){
    int u;scanf("%d",&u);
    int k;scanf("%d",&k);
    for(int j=0;j<k;j++){
      int v;scanf("%d",&v);
      ary[v-1][u-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      printf(j==n-1?"%d\n":"%d ",ary[j][i]);
    }
  }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

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

	int a[100][100] = {0};

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

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

	return 0;
}

C++: #include<stdio.h>
#define MAX 101

int main() {
    int n;
    int G[MAX][MAX];

    scanf("%d", &n);
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            G[i][j] = 0;
        }
    }

    int k, u, m;
    for (int i=1; i<=n; i++) {
        scanf("%d", &u);
        scanf("%d", &m);
        for (int j=1; j<=m; j++) {
            scanf("%d", &k);
            G[u][k] = 1;
        }
    }

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (j==1) printf("%d", G[i][j]);
            else printf(" %d", G[i][j]);
        }
        printf("\n");
    }

    return 0;
}

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

class branch{
  int to;
  branch(int to){
    this->to = to;
  }
};

int main(){
  int n; cin >> n;
  vector<branch> graph[n+1];
  int g[n+1][n+1];
  memset(g, 0, sizeof(g));

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

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

  return 0;
}

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

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

C++: #include<iostream>
#include<vector>

using namespace std;

class Graph{
private:
 vector< vector<unsigned long> > graph;
public:

 Graph(unsigned long num) : graph(num+1, vector<unsigned long>(num+1, 0)){
  for(unsigned long row_i = 0; row_i < num; ++row_i){
   unsigned long nodeNum = 0; cin >> nodeNum;
   unsigned long nodeMax = 0; cin >> nodeMax;

   for(unsigned long node_i = 0; node_i < nodeMax; ++node_i){
    unsigned long adjectNode = 0; cin >> adjectNode;

    graph[nodeNum][adjectNode] = 1;
   }
  }

 };

 void display(){
  for(unsigned long i = 1, num = graph.size(); i < num; ++i){
   for(unsigned long j = 1; j < num; ++j){
    if(j != 1) cout << " ";
    cout << graph[i][j];
   }
   cout << endl;
  }
 };

protected:
};

int main(){

 unsigned long num = 0; cin >> num;

 Graph g(num);
 g.display();

 return 0;
};

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

int main(void) {
    int  n;
    cin>>n;
    int g[101][101];
    for (int i = 0; i < n;i++) {
        for (int j = 0; j<n;j++) {
            g[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            g[u][v] = 1;
        }
    }
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            if(j) cout<<" ";
            cout<<g[i][j];
        }
        cout<<"\n";
    }
    return 0;
}