Go: package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	graph := make([][]int, N)
	for i := range graph {
		graph[i] = make([]int, N)
		var u, k int
		fmt.Scan(&u, &k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			v--
			graph[i][v] = 1
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if j > 0 {
				fmt.Print(" ")
			}
			fmt.Print(graph[i][j])
		}
		fmt.Println()
	}
}

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

class TVertex
{
    int FValue;
    std::vector<TVertex*> FList;
public:
    TVertex(int Value)
     : FValue(Value)
    {}
    void AddPath(TVertex* Vertex)
    {
        FList.push_back(Vertex);
    }
    void PrintMatrix(std::ostream& out, int MaxIndex)const
    {
        std::vector<TVertex*>::const_iterator It = FList.begin();
        for(int i = 1; i < MaxIndex; ++i){
            if(i > 1) out << " ";
            if(It != FList.end() && (*It)->FValue == i){
                out << 1;
                ++It;
            }else{
                out << 0;
            }
        }
        out << std::endl;
    }
};
class TGraph
{
    std::vector<TVertex*> FTable;
    void Init(int n)
    {
        assert(n > 0);
        FTable.resize(n);
        for(int i = 0; i < n; ++i){
            FTable[i] = new TVertex(i);
        }
    }
public:
    TGraph(int n)
    {
        Init(n+1);
    }
    
    void SetupVertex(std::istream& in)
    {
        int Index;
        in >> Index;
        assert(Index >= 1);
        assert(Index <= FTable.size());
        int k;
        in >> k;
        for(int i = 0; i < k; ++i){
            int v;
            in >> v;
            FTable[Index]->AddPath(FTable[v]);
        }
    }
    void PrintMatrix(std::ostream& out)
    {
        for(int i = 1; i < FTable.size(); ++i){
            FTable[i]->PrintMatrix(out, FTable.size());
        }
    }
};

int main()
{
    int n;
    std::cin >> n;
    TGraph Graph(n);
    for(int i = 0; i < n; ++i){
        Graph.SetupVertex(std::cin);
    }
    Graph.PrintMatrix(std::cout);
    return 0;
    
}

C++: int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j] << " ";
        }
        cout << endl;
    }
}

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

int main()
{
  int n;
  cin >>n;
  int u, a[n][n], v, num;
  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 >> num >> u;
    for(int j=0; j<u; j++){
      cin >> v;
      a[i][v-1] += 1;

    }
    for(int k=0; k<n-1; k++){
      cout << a[i][k] << ' ';
    }
    cout << a[i][n-1] <<endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int T[100][100];

void init(){
	for (int i = 0; i < 100; ++i)
	{
		for (int j = 0; j < 100; ++j)
		{
			T[i][j] = 0;
		}
	}
}

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

int main(){
	int n;
	cin >> n;
	init();
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			T[u-1][v-1] = 1;	
		}
	}
	DispTable(n);
	return 0;
}

C++: #include <iostream>

using namespace std;

#define N_MAX 100

int main()
{
    int n, i, j, u, k, v;
    int Adj[N_MAX][N_MAX] = {};

    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> u >> k;
        while (k-- > 0) {
            cin >> v;
            Adj[u-1][v-1] = 1;
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < n ; j++) {
            if (j == n - 1)
                cout << Adj[i][j] << endl;
            else
                cout << Adj[i][j] << ' ';
            /*
            cout << Adj[i][j] << ' ';
            if (j == n - 1)
                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) {
                    if(j!=n){
                        cout << 1 <<" "; hantei=1;
                    }else{
                        cout << 1 ;
                    }    
                }
            }
            if(hantei==0){ 
                if(i!=n){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            };
        }cout << endl;
    }
}

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

const int maxn = 100 + 5;

int ch[maxn][maxn];

int main(){
	char c;
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n; i++){
		int u,k,v;
		scanf("%d%d",&u,&k);
		for(int j = 1;j <= k; j++){
			scanf("%d",&v);
			ch[u][v] = 1;
		}
	}
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= n; j++){
			if(j != 1)printf(" ");
			printf("%d",ch[i][j]);
		}
		printf("\n");
	}
}

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

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 <cstdio>
#include <iostream>
#define MAX_VERTEXES 100
#define ZERO 0

using namespace std;

//think easy make easy

int n;//num of vertexes(頂点)
int matrix_graph[MAX_VERTEXES+1+1][MAX_VERTEXES+1+1];//1オリジン

int main(){
	scanf("%d",&n);

	int v_num;
	int k;//v_numの出次数

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			matrix_graph[i][j] = ZERO;
		}
	}

	for(int i=0;i<n;i++){
		scanf("%d",&v_num);
		scanf("%d",&k);

		for(int j=0;j<k;j++){
			int v_num2;
			scanf("%d",&v_num2);
			matrix_graph[v_num][v_num2] = 1;
		}
	}

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

	return 0;
}

C++: #include <iostream>

using namespace std;



int main(){

  int n,u,k,x;
  int array[124][124] = {{}};
  cin >> n;



  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> x;
      array[u - 1][x - 1] = 1;
    }
  }
  for (int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cout << " " << array[i][j];
    }
    cout << endl;
  }
}

C++: #include<cstdio>
int m[101][101];

int main(){
	int i,n,j,k,u,v;
	scanf("%d",&n);
	v = n;
	while(n--){
		scanf("%d",&u);
		scanf("%d",&j);
		while(j--){
			scanf("%d",&i);
			m[u][i] = 1;
		}
	}
	for( i = 1; i <= v; i++ ){
		for( j = 1; j <= v; j++ ){
			if(j!=1) printf(" ");
			printf("%d",m[i][j]);
		}
		printf("\n");
	}
}