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 <map>
#include <set>
#include <algorithm>
using namespace std;
#define MAX 100000

int main(){
  int n;
  cin >>n;
  int A[n+2][n+2]={0};
  int t,k,l,
  for(int i=1;i<=n;i++){
    cin >> t >> k;
    for(int j=1;j<=k;j++){
      cin >> l;
      A[i][l]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;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] //0 origin Adjacency matrix
    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--; //0 origin
        for(int j = 0; j < k; j++)
        {
            cin >> v;
            v--; //0 origin
            M[u][v]=1;//uとvの間に辺を張る
        }
    }


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

C++: #include<stdio.h>

int main(){
  int i,j,n,k,c,b;

  int a[124][124]={{}};

  scanf("%d",&n);
  for(i=0;i<n;i++){

    scanf("%d %d",&c,&b);
    for(j=0;j<b;j++){
      scanf("%d",&k);
      a[c-1][k-1]=1;

    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
       printf("%d",a[i][j]);
      if(j!=0){
	printf(" ");
    
    }
    }
    
    puts("");
 
}
  return 0;
}

C++: #include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
int graph[101][101];
int main(){
    int n,u,k,v;
    scanf("%d",&n);
    fill(graph[0],graph[100],0);
    REP(i,n){
        scanf("%d%d",&u,&k);
        REP(j,k){
            scanf("%d",&v);
            graph[u][v]=1;
        }
    }
    REP(i,n){
        REP(j,n){
            if(j) printf(" ");
            printf("%d",graph[i+1][j+1]);
        }
        puts("");
    }
    return 0;
}

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

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

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

int n;
int E[MAX][MAX];

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

C++: #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

int main() {
  int n, u, k, v;
  cin >> n;
  vector<vi> adj(n, vi(n, 0));
  REP(i, n) {
    cin >> u >> k;
    REP(j, k) {
      cin >> v;
      adj[u - 1][v - 1] = 1;
    }
  }
  REP(i, n) print(adj[i]);
}

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

int n;
int M[101][101];
int main() {
    cin >> n;

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

    for (int l = 1; l <= n; ++l) {
        for (int i = 1; i <= n; ++i) {
            if(i != 1)
            cout << M[l][i] ;
        }
        cout << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	bool f[100][100];
	for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)f[i][j] = false;
	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;
			f[u - 1][v - 1] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j)cout << " ";
			cout << f[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	int M[N][N]; // 0 0 起点的邻接矩阵 
	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--;		//转换为0起点 
		for(int j = 0;j < k;j++){
			cin >> v;
			v--;
			M[u][v] = 1; //在u和v之间画出一条边 
		}
	}
	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;
#define MAX 100
int N[MAX][MAX];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            N[i][j] = 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;
            N[i][v-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j!=0) cout<<" ";
            cout<<N[i][j];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;


int main(){

  int n;
  int G[105][105];

  cin >> n;

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

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

}

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>
#define rep(i, n) for (int i=0; i<(n); i++)
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--; //0オリジンへ変換
    rep(j, k) {
      cin>>v;
      v--; //0オリジンへ変換
      M[u][v]=1;//uとvの辺を張る
    }
  }

  rep(i, n) {
    rep(j, n) {
      if (j) cout<<" ";
      cout<<M[i][j];
    }
    cout<<endl;
  }

  return 0;
}