Go: package main
import (
	"fmt"
	"bufio"
	"os"
	"bytes"
	"strconv"
	"strings"
)

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num , _ :=  strconv.Atoi(scanner.Text())
	return num
}


func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	N := nextInt(scanner)
	var A [][]int = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = make([]int, N)
	}
	for i:=0; i<N; i++{
		idx := nextInt(scanner)
		cnt := nextInt(scanner)
		for j:=0; j<cnt; j++ {
			node := nextInt(scanner)
			A[idx-1][node-1] = 1
		}
	}
	var outBuffer bytes.Buffer
	for i:=0; i<N; i++ {
		outBuffer.WriteString(strings.TrimRight(fmt.Sprintf("%v",A[i])[1:], "]") + "\n")
	}
	fmt.Printf("%s", outBuffer.String())
}

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

int main() {
	
	int i, j, n, u, k, v, maxu, a[102][102] = {};
	
	cin >> n;
	maxu = 0;
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		for (j = 0; j < k; j++) {
			cin >> v;
			a[u][v] = 1;
			maxu = max(maxu, u);
		}
	}

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

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

static const int N=100;

int main()
{
    int M[100][100];
    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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;


int main() {
  int n;
  cin >> n;
  int m[n][n];
  rep(i, n){
    rep(j,n){
      m[i][j] = 0;
    }
  }
  rep(i,n){
    int u, k;
    cin >> u >> k;
    u--;
    rep(j,k){
      int v;
      cin >> v;
      v--;
      m[u][v] = 1;
    }
  }
  rep(i,n){
    rep(j,n){
      cout << m[i][j] << (j == n - 1 ? "\n" : " ");
    }
  }
}

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>(4,0));

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

	cout << "test" << endl;

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

	return 0;
}

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

int main() {
    int n; cin >> n;
    int adj_mat[n][n];

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

    for (int i = 0; i < n; i++) {
        int m, l; cin >> m >> l;
        for (int j = 0; j < l; j++) {
            int k; cin >> k;
            adj_mat[i][k-1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) cout << " ";
            cout << adj_mat[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+1;m++){
	cout<<ushi[k][m]<<" ";}
      cout<<endl;}
}

C++: #include <cstdio>
#include <vector>

int main(){
	std::vector< std::vector<int> > M;
	int n, r, k, c;
	scanf("%d", &n);
	M.resize(n);
	for (int i=0;i<n;i++){
		M[i].resize(n);
		scanf("%d %d", &r, &k);
		for (int j=0; j<k;j++){
			scanf("%d", &c);
			M[i][c-1]=1;
		}
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			printf("%d", M[i][j]);
                        if (j!=n-1) printf(" ");
		}
		printf("\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++){
        for(int j=0;j<n;j++){
            g[i][j]=0;
        }
    }
    int u;
    int k;
    int p;
    for(int i=0;i<n;i++){
        cin>>u;
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>p;
            g[u-1][p-1]=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];
        cout<<endl;
    }
    return 0;
}

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

int main(){
  int a,m[101][101],b,c,d;
  cin >> a;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      m[i][j]=0;
    }
  }
  for(int i=1;i<=a;i++){
    cin >> b >> c;
    for(int j=0;j<c;j++){
      cin >> d;
      m[i][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout << m[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n,u,m,c;
  int b[1000][1000] = {};
  int a[1000][1000] = {};

  cin >> n;//点の数を入力する

  for(int i = 1;i <=n ;i++){
    cin >> u >> m;//次数を入力する
    for(int j = 1;j <= m;j++){
      cin >> b[u][j];//b[点の番号][接続先]
    }
  }

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

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#pragma warning(disable:4996)
int main()
{
	int u, k, n, v;
	int i, j;
	int matrix[100][100] = {0};

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


	return 0;

}

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

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

C++: #include <iostream>

#define MAX 110
using namespace std;

int main(){
    int num; cin >> num;
    int matrix[MAX][MAX];
    for(int i=0;i<MAX;i++){
        for(int j=0;j<MAX;j++){
            matrix[i][j] = 0;
        }
    }
    for(int i=1;i<=num;i++){
        int v; cin >> v;
        int tmp; cin >>tmp;
        for(int j=0;j<tmp;j++){
            int vi; cin >> vi;
            matrix[v-1][vi-1] = 1;
        }
    }
    for(int i=0;i<num;i++){
        for(int j=0;j<num;j++){
            if(j==0)
                cout << matrix[i][j];
            else
                cout << " " << matrix[i][j];
        }
        cout << endl;
    }
}