Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	for i := 0; i < num; i++ {
		sc.Scan()
		sc.Text()
		sc.Scan()
		num2, _ := strconv.Atoi(sc.Text())
		r := make([]int, num)
		for j := 0; j < num2; j++ {
			sc.Scan()
			val, _ := strconv.Atoi(sc.Text())
			r[val-1] = 1
		}
		for i, v := range r {
			if i != 0 {
				fmt.Printf(" %v", v)
			} else {
				fmt.Printf("%v", v)
			}
		}
		fmt.Println()
	}
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#define mop 1000000007

using namespace std;
int m[101][101] = {};

int main() {
    
    int n;
    cin >> n;
    for (int i=0;i<n;i++){
        int p,k;
        cin >> p >> k;
        for (int j=0;j<k;j++){
            int q;
            cin >> q;
            m[i+1][q] = 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;
    }


}

C++: #include <iostream>
using ll = long long;
using namespace std;
/* initialize */

/* main */
int main() {
    int n,u,k, v;
    int A[100][100];
    cin >> 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 >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            A[u-1][v-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] << "\n";
    }
    return 0;
}

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

C++: #include<iostream>

int main() {
	int node_num, adj[100][100];

	std::cin >> node_num;

	for (int i = 0; i < node_num; i++)
		for (int j = 0; j < node_num; j++)
			adj[i][j] = 0;

	for (int i = 0; i < node_num; i++) {
		int node, num;
		std::cin >> node >> num;
		for (int j = 0; j < num; j++) {
			int n;
			std::cin >> n;
			adj[node - 1][n - 1] = 1;
		}
	}

	for (int i = 0; i < node_num; i++) {
		for (int j = 0; j < node_num; j++) {
			std::cout << adj[i][j] << (j != node_num - 1 ? " ":"");
		}
		std::cout << std::endl;
	}
}

C++: /*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,c,g[105][105]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a >> b;
    a--;
    for(int j=0; j<b; j++) {
      cin >> c;
      c--;
      g[a][c]=1;
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n-1; j++) {
      cout << g[i][j] << " ";
    }
    cout << g[i][n-1] << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        if(i!=n-1){
            cout<<"\n";
        }
    }
    
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        if(i<n-1){
            cout<<"\n";
        }
    }
    
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

bool G[100][100];

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

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

    rep(i, N) {
        rep(j, N) {
            if (j > 0) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;


static const int N = 100;

int main(){
  int M[N][N];
  int n, u, k, v;

  cin >> n;
  REP(i,n){
    REP(j,n){
      M[i][j] = 0; //初期化
    }
  }

REP(i,n){
  cin >> u >> k;
  u--;  //オリジンに変換
  
  REP(j,k){
    cin >> v;
    v--;
    M[u][v] = 1;
  }
}

REP(i,n){
  REP(j,n){
    if(j) cout << " ";
    cout << M[i][j];

  }
  cout << endl;
}


return 0;


}

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

int ari;
int jigoku[102];
int u[102];
int v[102][102];
int ushi[102][102];
int main(){
  cin>>ari;
  for(int i=1;i<ari+1;i++){
    cin>>u[i]>>jigoku[u[i]];
      for(int j=1;j<jigoku[u[i]]+1;j++){
	cin>>v[u[i]][j];
      }
  }
  //for(int uma=1;uma<ari+1;uma++){cout<<u[uma];}
  for(int k=1;k<ari+1;k++){
    for(int l=1;l<jigoku[k]+1;l++){
      for(int m=1;m<ari+1;m++){
	//cout<<v[k][l];
	if(v[k][l]==u[m]){ushi[k][m]=1;}
	//cout<<ushi[k][m];
      }
    }
  }
    for(int k=1;k<ari+1;k++){
      for(int m=1;m<ari;m++){
	cout<<ushi[k][m]<<" ";
      }cout<<ushi[k][ari];
      cout<<endl;}
}

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

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

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

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

    return 0;
}