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;
int main(){
    int n;
    cin >> n;
    vector<vector<int> > mat(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        int u,k;
        cin >> u >> k;
        for(int j=0;j<k;j++){
            int v;
            cin >> v;
            mat.at(u-1).at(v-1)=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << mat.at(i).at(j);
            if(j==n-1) cout << endl;
            else cout << " ";
        }
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef vector<vector<int>> matrix;

int main()
{
    // 入力
    int N;
    cin >> N;
    matrix G(N + 1, vector<int>(N + 1, 0));

    for (int i = 0; i < N; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            G[u][v] = 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;
    }
}

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

int main() {
    int N = 0;
    int u, k, v;
    int G[101][101] = {};
    scanf("%d", &N);
    
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &u, &k);

        for (int j = 0; j < k; j++) {
            scanf("%d", &v);
            G[u][v] = 1;
        }
    }
    
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (j != 1) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int n;
int e1[105][105];
int main(){
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    int u,k;
    scanf("%d%d",&u,&k);
    u--;
    for(int j = 0; j < k; j++){
      int a;
      scanf("%d",&a);
      a--;
      e1[u][a] = 1;
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      printf("%d",e1[i][j]);
      if(j!=n-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

C++: // 最長共通部分列 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100
// 無効な値の定義
const int INV = -1;

int main(void)
{
    int n, u, num, v_num;
    int ary_adj[MAX_N];

    for(int i = 0; i < MAX_N; i++)
    {
        // 配列の初期化
        ary_adj[i] = 0;
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> u;
        cin >> num;

        for(int j = 0; j < num; j++)
        {
            // 隣接点を記憶する
            cin >> v_num;
            ary_adj[v_num] = 1;
        }

        // 結果の表示をする
        for(int k = 1; k <= n; k++)
        {
            if( k > 1 )
            {
                cout << " ";
            }

            if( ary_adj[k] == 1 )
            {
                cout << 1;
                ary_adj[k] = 0;
            }
            else
            {
                cout << 0;
            }
        }

        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
static const int N = 100;

#pragma warning( disable:4996 )

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 <stdio.h>
#define N 101

int main(){

  int u,k,i,j,v,n;
  int a[N][N];
  
  /*for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      a[i][j]=0;
    }
  }
  */
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][n]);
  }

  return 0;

}

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

int main(){

  int n;

  cin >> n;

  int c[n][n];

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

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

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


using namespace std;


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


  vector< vector<int> > a;
  for(int i=0;i<n;i++){
    int u;
    int k;
    cin >> u >> k;
    vector<int> tmpa;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      tmpa.push_back(tmp);
    }

    a.push_back(tmpa);
  }

  
  int a2[n][n]={0};  
  for(int i=0;i<n;i++){
    for(int j=0;j<(int)a[i].size();j++){
      a2[i][a[i][j]-1] = 1;
    }
  }

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

C++: #define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<vector<int>> G(100+1,vector<int>(100+1,0));

int main(void) {

    int n; cin>>n;

    for (int i = 1; i <= n; ++i) {
        int u,k; cin>>u>>k;
        for (int j = 1; j <= k; ++j) {
            int v; cin>>v;
            G[u][v]=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>
using namespace std;

int main()
{
 int i;
}

C++: #include <bits/stdc++.h>
using namespace std;
bool A[105][105];
int main()
{
	memset(A,0,sizeof(A));
	int n,v,u,du;
	cin>>n;
	getchar();
	for(int i=1;i<=n;i++){
		cin>>v>>du;
		while(du--)
			cin>>u,
			A[v][u] = 1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j==1) cout<<A[i][j];
			else cout<<' '<<A[i][j];
		}
		cout<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  int v[100][100]={};
  int u,k,a;
  cin >> n;
  rep(i,n){
    cin >> u >> k;
    u--;
    rep(j,k){
      cin >> a;
      a--;
      v[u][a]=1;
    }
  }
  rep(i,n){
    rep(j,n){
      if(j>0) cout << " " << v[i][j];
      else cout << v[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"
#define SP " "

int main() {

  int N;
  cin >> N;

  vector<vector<ll>> G(N, vector<ll>(N, 0));

  rep0(i, N) {
    int u, k;
    cin >> u >> k;
    rep0(j, k) {
      int v;
      cin >> v;
      G[i][v - 1] = 1;
    }
  }

  rep0(i, N) {
    rep0(j, N - 1) {
      cout << G[i][j] << SP;
    }
    cout << G[i][N - 1] << BR;
  }
  return 0;
}