Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

C++: #include <cstdio>

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

    int M[n][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++) {
        int u, degree;
        scanf("%d %d", &u, &degree);
        u--;    // convert to 0 index
        for (int j = 0; j < degree; j++) {
            int v;
            scanf("%d", &v);
            v--;    // convert to 0 index
            M[u][v] = 1;
        }
    }

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

C++: #include <iostream>
#include <cassert>
#include <string.h>
#include <vector>
#include <map>

using namespace std;

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

    vector<vector<int>> matrix;
    for (int i = 0; i < n; ++i)
    {
        vector<int> line;
        for (int j = 0; j < n; ++j)
        {
            line.push_back(0);
        }
        matrix.push_back(line);
    }

    for (int i = 0; i < n; ++i)
    {
        int vertex;
        int degree;

        cin >> vertex;
        cin >> degree;

        assert(vertex <= n);
        assert(degree <= n);

        for (int j = 0; j < degree; ++j)
        {
            int adj;
            cin >> adj;
            assert(adj <= n);
            matrix[vertex - 1][adj - 1] = 1;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            string delim = (j == (n - 1)) ? "\n" : " ";
            cout << matrix[i][j] << delim;
        }
    }

    return 0;
}

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

#define N 100

int main(void) {
    int n, u, k, v;
    int A[N + 1][N + 1] = {};
    
    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;
}

C++: #include<iostream>
using namespace std;
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--;
    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];
    }
    cout << endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int mat[n][n];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            mat[i][j] = 0;
        }
    }
    for(int i = 0; i < n; ++i){
        int id;
        cin >> id;
        int k;
        cin >> k;
        int v;
        for(int j = 0; j < k; ++j){
            cin >> v;
            mat[id-1][v-1] = 1;
        }
    }
    for(auto x : mat){
        for(int i = 0; i < n; ++i){
            if(i == 0){
                cout << x[i];
            } else {
                cout << ' ' << x[i];
            }
        }
        cout << endl;
    }
}

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

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

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

int main(int argc, char const *argv[])
{
    // 頂点数
    int cnt_vertex(0);

    cin >> cnt_vertex;
    vector<vector<int>> vecGraph(cnt_vertex,vector<int>(cnt_vertex,0));

    int num_vertex(0), cnt_exit_vertex(0);

    for (int i = 0; i < cnt_vertex; i++)
    {
        cin >> num_vertex >> cnt_exit_vertex;
        int num_next_vertex(0);
        for (int j = 0; j < cnt_exit_vertex; j++)
        {
            cin >> num_next_vertex;
            // cout << endl;
            // cout << cnt_vertex << endl;
            vecGraph[i][num_next_vertex-1] = 1;
        }
    }

    for (int i = 0; i < cnt_vertex; i++)
    {
        for (int j = 0; j < cnt_vertex; j++)
        {
            if(j == cnt_vertex-1) {
                cout << vecGraph[i][j] << "\n";
            } else {
                cout << vecGraph[i][j] << " ";
            }
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
 int dp[200][200] = {0};

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

 }
int main(){
  int n,u,k;
  int ad;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      dp[u][ad] = 1;
    }
  }
  pgraph(n);
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

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

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>

using namespace std;

static const int N = 100;

int main()
{
    int M[N][N];    // 0オリジンの隣接行列
    int n, u, k, v;
    int i, j;

    cin >> n;

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

    for (i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;        // 0オリジンへ変換
        for (j = 0; j < k; j++) {
            cin >> v;
            v--;    // 0オリジンへ変換
            M[u][v] = 1;    // u と v の間に辺を張る
        }
    }

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

    return 0;
}

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

using namespace std;

int N;

int main()
{
	cin >> N;

	vector<vector<bool> > M(N, vector<bool>(N));

	int u, k, v;

	for (int i = 0; i < N; i++)
	{
		cin >> u >> k;

		for (int i = 0; i < k; i++)
		{
			cin >> v;

			M[u - 1][v - 1] = true;
		}
	}

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