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<iostream>
//#include<cstdio>
using namespace std;

int main(){
  int n,u,k;
  int ad;
  int arr[200][200] = {0};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      arr[u][ad] = 1;
    }
  }

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

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

int main() {
    int n, idx, g_num, a;
    int G[MAX+1][MAX+1];

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> idx >> g_num;
        for(int j=0; j<=n; j++) {
            G[idx][j] = 0;
        }
        for(int j=0; j<g_num; j++) {
            cin >> a;
            G[idx][a] = 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>
#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(j!=n){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            };
        }cout << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int u,k,v;
    int A[100][100]={{}};
    for(int i=0;i<n;i++){
         cin>>u>>k;
         if(k!=0){
             for(int i=0;i<k;i++){
                cin>>v;
                A[u-1][v-1]=1;
             }
         }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==0){
            cout<< A[i][j];
            }
            else{
                cout<<" "<<A[i][j];
            }
        }
        cout<<endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


int n;
int g[110][110];

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

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

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>

using namespace std;


int main() {
	int n;
	int u, v;
	int Adj[101][101];
	int deg;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			Adj[i][j] = 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		cin >> u;
		cin >> deg;
		for (int j = 1; j <= deg; j++) {
			cin >> v;
			Adj[u][v] = 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			printf("%d", Adj[i][j]);
			if (j != n) {
				printf(" ");
			}
		}
		printf("\n");
	}
}

C++: #include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define INFTY 2000000001
#define MAX 101

int n = 0;
int adl[MAX][MAX], deg[MAX];
int adm[MAX][MAX];

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      adm[i][j] = 0;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int num;
    scanf("%d", &num);
    num--;
    scanf("%d", &deg[num]);
    for ( int j = 0; j < deg[num]; j++) {
      scanf("%d", &adl[num][j]);
      adl[num][j]--;
      adm[num][adl[num][j]] = 1;
    }
  }

  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n-1; j++ ) {
      printf("%d ", adm[i][j]);
    }
    printf("%d\n", adm[i][n-1]);
  }

  return 0;
}

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

//隣接行列
int d[101][101];

int main(){
  
  int u,k,v,n;
  cin >> n;
  //入力
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v;
      d[u][v] = 1;//隣接しているところを1にする
    }
  }
  //出力
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      //最後に空白が入らないようにする
      if(j == n){
	cout << d[i][j];
      }else{
	cout << d[i][j] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}

C++: int main(){ //??°???????????£??\??????????????£??\?????????????????????????????°??????
    
    int n,k,v,w;
    
    cin >> n; //??°????????????????????\???
    
    Matrix M(n,Array(n,0)); //??£??\??????????????????
    
    for (int i=0; i<n; i++) { //??????????¬???°?????????????????\??? ???????????\??????????????£??\??????????????£??\?????????????´?
        cin >> w >> k;
        for (int j=0; j<k; j++) {
            cin >> v;
            M[w-1][v-1] = 1; //?????????
        }
    }
    
    for (int i=0; i<n; i++) { //????????¢?????§??????
        for (int j=0; j<n; j++) {
            cout << M[i][j];
            if (j!=n-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    
    return 0;
}

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

int G[101][101];

int main(){
  int n, u, k, v;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v;
      G[u][v] = 1;
    }
  }
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n; j++)
      cout << G[i][j] << (j == n ? '\n' : ' ');
  return 0;
}

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

int n, u, k, v, a[101][101] = { 0 };

int main(){
	cin >> n;
	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++) {
		cout << a[i][1];
		for (int j = 2; j <= n; j++) {
			cout << " " << a[i][j];
		}
		cout << endl;
	}

	return 0;
}