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 <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int G[n][n];
  rep(i,n) memset(G[i], 0, sizeof(G[i]));
  int u, k;
  rep(i,n) {
    cin >> u >> k;
    rep(j,k) {
      int t;
      cin >> t;
      G[i][t-1] = 1;
    }
  }

  rep(i,n) {
    rep(j,n) printf("%d%c", G[i][j], (j==n-1 ? '\n' : ' '));
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector< vector<int> > g_matrix;
    g_matrix = vector< vector<int> >(n, vector<int>(n, 0));
    
    for(int i = 0; i < n; i++){
        int u, k;
        scanf("%d %d", &u, &k);
        u--;
        for(int j = 0; j < k; j++){
            int v;
            scanf("%d", &v);
            v--;
            g_matrix[u][v] = 1;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n - 1; j++){
            printf("%d ", g_matrix[i][j]);
        }
        printf("%d", g_matrix[i][n - 1]);
        printf("\n");
    }
    return 0;
}

C++: #include<iostream>
#include <cstdlib>
#include<list>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<stack>
#define MAX 101
using namespace std;
int main() {
	int n, a, k, d, data[MAX][MAX] = { 0,0 }; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> d;
			data[i][d - 1] = 1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (j)cout << " ";
			cout << data[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int n, u, k, v;
int Adj[MAX_N][MAX_N];

void initialize(){
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			Adj[i][j] = 0;
		}
	}
}

void check_adj(){
	Adj[u][v] = 1;
}

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

int main(void){
	cin >> n;
	initialize();
	for(int i = 0; i < n; i++){
		cin >> u;
		u--;
		cin >> k;
		for(int j = 0; j < k; j++){
			cin >> v;
			v--;
			check_adj();
		}
	}
	print_adj();

	return 0;
}

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

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

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

int main() {
    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--;
        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 > 0) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
    int n, u, k, tmp;
    cin >> 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++) {
        cin >> u >> k;
        for (int j=0; j<k; j++) {
            cin >> tmp;
            M[u-1][tmp-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 << ' ';
            } else {
                cout << endl;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>

using namespace std;
int main() {
	int n,m,l,p;
	cin >> n;
	bool a[n][n];
	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 >> m;
		cin >> l;
		for(int j = 0; j < l;j++) {
			cin >> p;
			a[m-1][p-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>
using namespace std;

int v[100][100];

signed main()
{
  int n;
  int u, k;

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

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

  return (0);
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int n;
    cin >> n;

    int A[n+10][n+10]={};
    int p,k;
    rep(i,n){
        cin >> p >> k;
        int q;
            rep(j,k){
                cin >> q;
                A[p][q] = 1;
            }
    }

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

C++: //16D8103012G 三品海渡
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 2; j < n; j++)
	{
	  if (ln[i][j] != 0 && m[j][i]==0)
	    {
	      m[i][ln[i][j]-1] = 1;
	    }
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
	{
	  cout << m[i][j] << " ";
	}
      cout << endl;
    }
  return 0;
}

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

int main() {
    int n, u, k, v;
    cin >> 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++) {
        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 != 0) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
}

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

int G[110][110] ={0};

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