Go: package main

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

const N = 100

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var M [N][N]int
	for i := 0; i < n; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		u--
		for j := 0; j < k; j++ {
			sc.Scan()
			v, _ := strconv.Atoi(sc.Text())
			v--
			M[u][v] = 1
		}
	}

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				out.WriteString(" ")
			}
			out.WriteString(fmt.Sprintf("%d", M[i][j]))
		}
		out.WriteString("\n")
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}

C++: //16D8103013E Sen Shunkou
#include<iostream>
int main(){
    int n;
    std::cin>>n;
    int A[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    int tmp,s,e;
    for(int i=0;i<n;i++){
        std::cin>>s;
        std::cin>>tmp;
        for(int j=0;j<tmp;j++){
            std::cin>>e;
            A[s-1][e-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==0){
                std::cout<<A[i][j];
            }else std::cout<<" "<<A[i][j];
        }
        std::cout<<"\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vvll edges(n, vll(n, 0));
  REP(i, n) {
    ll u, K; cin >> u >> K;
    REP(k, K) {
      ll to; cin >> to;
      edges.at(u-1).at(to-1) = 1;
    }
  }
  REP(i, n){
    REP(j, n) {
      cout << edges.at(i).at(j);
      if (j != n-1) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

const int N_MAX = 100;

// グラフ
// 隣接リスト表現の有効グラフGの隣接行列を出力

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cout << "hello world" << endl;

    int n;
    cin >> n;

    int G[100][100] = { 0 };

    for (int i = 0; i< n; i++)
    {
        int u, k;
        cin >> u; // 頂点番号
        cin >> k; // 出次数
        for (int i = 0; i < k; i++)
        {
            int v;
            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;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vint;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)

int main(){
    int n;
    cin >> n;
    vector<vint> A(n,vint(n,0));
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v;
            cin >> v;
            A[u-1][v-1]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout << A[i][j];
            if(j<n-1) cout << ' ';
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 2; j < n; j++)
	{
	  if (ln[i][j] != 0 )
	    {
	      m[i][ln[i][j]-1] = 1;
	    }
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
	{
	  cout << m[i][j] << " ";
	}
      cout << endl;
    }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int H[110][110];
int main()
{
    int n,m,a,b;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        scanf("%d",&a);
        for(int i=0;i<a;i++)
        {
            scanf("%d",&b);
            H[m][b]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        printf("%d ",H[i][j]);
        printf("\n");
    }
    return 0;
}

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

int ari;
int jiku[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];
    cin>>jiku[u[i]];
      for(int j=1;j<jiku[u[i]]+1;j++){
	cin>>v[u[i]][j];
      }
  }
  for(int k=1;k<ari+1;k++){
  //	cout << jiku[k] << endl;
    for(int l=1;l<jiku[k]+1;l++){
    //	cout << k << " " << l << endl;
      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 <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<vector<int> > mat(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    int u = -1, k = -1, v = -1;
    fscanf(stdin, "%d %d", &u, &k);
    for (int j = 0; j < k; ++j) {
      fscanf(stdin, "%d", &v);
      mat[u - 1][v - 1] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j) { fprintf(stdout, " "); }
      fprintf(stdout, "%d", mat[i][j]);
    }
    fprintf(stdout, "\n");
  }
  return 0;
}

C++: #include<iostream>

using namespace std;
 
int main()
{
  int g[100][100];
  int n;
  
  for(int i=0; i<100; i++)
    {
      for(int j=0; j<100; j++)
	{
	  g[i][j]=0;
        }
    }
  
  cin>>n;

  int x,y,z;
    
  for(int i=0; i<n; i++)
    {
      cin>>x>>y;
      for(int j=0; j<y; j++)
	{
	  cin>>z;
	  g[x-1][z-1]=1;
        }
    }
  
  for(int i=0; i<n; i++)
    {
      for(int j=0; j<n; j++)
	{
	  if(j!=0) cout<<" ";
	  cout<<g[i][j];
        }
      cout<<'\n';
    }
    return 0;
}

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

int main()
{
    int n,u,v,d;
    int G[101][101];
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            G[i][j]=0;
    for(int i=0;i<n;i++)
    {
        cin>>u>>d;
        for(int k=0;k<d;k++)
        {
            cin>>v;
            G[u][v]=1;
            //cout<<u<<' '<<v<<' '<<G[u][v]<<endl;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int isn=0;
        for(int j=1;j<=n;j++)
        {
            if(isn++>0)cout<<' ';
            cout<<G[i][j];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int adj[100][100] = {0};
int main()
{
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		int j, k;
		cin >> j >> k;
		j--;
		for (int m=0;m<k;m++) {
			int a;
			cin >> a;
			a--;
			adj[j][a]=1;
		}
	}

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

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 (i!==n-1) cout << " ";
		}
		cout<<endl;
	}
}