Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

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

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

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_graph[MAX_N + 1][MAX_N + 1];

    for(int i = 0; i < MAX_N + 1; i++)
    {
        for(int j = 0; j < MAX_N + 1; j++)
        {
            // 配列の初期化
            ary_graph[i][j] = 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_graph[u][v_num] = 1;
        }
    }

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

            cout << ary_graph[i][j];
        }

        cout << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

int main(){
	
	int n;
	cin >> n;
	vector<vector<int>> ans(n,vector<int>(n,0));

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

	rep(i,n){
		rep(j,n-1){
			cout << ans[i][j] << " ";	
		}
		cout << ans[i][n-1] << endl;
	}

	return 0;
}

C++: #include <stdio.h>
#define N 101

int main(){

  int u,k,i,j,v,n;
  int a[N][N];
 
  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++){
      if(a[i][j]==NULL)a[i][j]=0;
    }
  }
  
  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 "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define loop(i) for(int i = 0;true; i++)
#define all(x) (x).begin(), (x).end()
#define mn 1000000007
int main() {
	int N;
	cin >> N;
	vvi A(N,vi(N,0));
	for (int i = 0; i < N; i++)
	{
		int u,k;
		cin >> u;
		cin >> k;
		u--;
		for (int j = 0; j < k; j++)
		{
			int temp;
			cin >> temp;
			temp--;
			A[u][temp] = 1;
		}
	}
	rep(i, 0, N) {
		rep(j,0,N) {
			if (j != 0) {
				cout << " ";
			}
			cout << A[i][j];
		}
		cout << endl;
	}
};

C++: #include<iostream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REP(j, n) for(int j = 0;j < n;j++)
using namespace std;

int main()
{
	int i,n,u,k;
	int v[100][100];
	cin >> n;
	REP(i,n){
		cin >> u;
		REP(i,u){
			cin >> k;
			cin >>v[i][k];
		}
	}
	REP(i,n){
		REP(j,n){
			cout << v[i][j] << " ";
		}
		cout<<endl;
	}
}

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

int main(){

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

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

  for(int i=0; i<n; i++){
    int u, k;
    scanf("%d %d", &u, &k);
    for(int j=0; j<k; j++){
      int adj;
      scanf("%d", &adj);
      M[u][adj] = 1;
    }
  }

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

  return 0;
}

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

using namespace std;

//グラフの表現
int main(){
	int n;
	int M[101][101] = {};
	cin >> n;

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

const static int N = 100;

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

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

  return 0;    
}

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

int main( void ){
  int M[N][N];
  int n,m,l,k;
 
  cin >> n;

  for( int i = 0 ; i < n ; i++ ){
    for( int j = 0 ; j < n ; j++ ){
      M[i][j];
    }
  }
  for( int i = 0 ; i < n ; i++ ){
    cin >> m >> l;
    m--;
    for( int j = 0 ; j < l ; j++ ){
      cin >> k;
      k--;
      M[m][k] = 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;
#define rep(i,n) for ( int i = 0; i < (n); ++i)
static const int N = 100;

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


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

C++: #include<iostream>

using namespace std;
const int N = 100;

int main() {

	int n, u, k, v;
    int A[N][N];

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