Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

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

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<4; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      cout << " ";
      }

      cout << endl;
    }
  }

C++: #include <iostream>
#include <vector>
using namespace std;
vector<vector<int> > v(101);
int dp[101][2] = { 0 };
int n, t = 0;
 
void dfs(int a) {
    if (dp[a][0] == 0) { t++; dp[a][0] = t; }
    else { return; }
    for (int i = 0;i < v[a].size();i++) {
        if (dp[v[a][i]][0] == 0) {
            dfs(v[a][i]);
        }
    }
    if (dp[a][1] == 0) { t++; dp[a][1] = t; }
}
 
int main() {
    cin >> n;
    for (int i = 0; i < n;i++) {
        int u,k; cin >> u >> k;
        for (int j = 0; j < k;j++) {
            int x; cin >> x;
            v[u].push_back(x);
        }
    }
    for (int i = 1; i <= n;i++) {
        dfs(i);
    }
    for (int i = 1; i <= n;i++) {
        cout << i << ' ' << dp[i][0] << ' ' << dp[i][1] << endl;
    }
}

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

int n, u, k, uk;
int G[101][101] = {0};

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> u >> k;
		while (k --) {
			cin >> uk;
			G[u][uk] = 1;
		}
	}
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=n; ++j) {
			cout << G[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int v,a[100][100]{};
    cin >> v;
    REP(i,v){
        int n,m;
        cin >> n >> m;
        REP(j,m){
            int u;
            cin >> u;
            a[i][u-1]=1;
        }
    }
    REP(i,v){
        cout << a[i][0];
        FOR(j,1,v){
            cout << " " << a[i][j];
        }
        cout << endl;
    }
    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]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n,u,k,m;
    int v[1000][1000]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int l=1;l<=k;l++){
            cin>>m;        
            v[u][m]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j==n){
                cout<<v[i][j];
            }
            else{
                cout<<v[i][j]<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}

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

int G[MAX][MAX];

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

void input(int n) {
	int m, g, k;
	for (int i = 0; i < n; i++) {
		cin >> m >> k;
		--m;
		for (int j = 0; j < k; j++) {
			cin >> g;
			--g;
			G[m][g] = 1;
		}
	}
}

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

int main() {
	int size;
	cin >> size;
	arrayInit(size);
	input(size);
	output(size);
	return 0;
}

C++: #include<stdio.h>

#define MAX 107

int gragh [MAX][MAX];

int v[MAX];

int main(){
  int n,i,j;
  int vertex,num;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){    
      gragh[i][j] = 0;
    }
  }
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&vertex,&num);
    for(j=1;j<=num;j++){
      scanf("%d",&v[j]);
      gragh[vertex][v[j]] = 1;
    }
  }

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



  return 0;
}

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

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

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

int n;
int k;
int m;

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

  // int型の2次元配列(3×4要素の)の宣言
  vector<vector<int>> A(n, vector<int>(n));

  for (int i=0; i<n; i++) {
    cin >> V[i];
    cin >> k;
    if (k==0) {
      continue;
    } else {
      for (int j =0; j<k; j++) {
        cin >> m;
        A[i][m-1] = 1;
      }
    }
  }

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



 
}

C++: // -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_11_A: Graph

#include <cstdio>
#include <cstring>

int main()
{
  unsigned int n;
  std::scanf("%u", &n);

  int g[n][n];
  std::memset(g, 0, sizeof(g));

  unsigned int u, k, v;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u %u", &u, &k);
    for (auto j = 0u; j < k; ++j) {
      std::scanf("%u", &v);
      g[u-1][v-1] = 1;
    }
  }

  for (auto i = 0u; i < n; ++i) {
    const char* sep = "";
    for (auto j = 0u; j < n; ++j) {
      std::printf("%s%d", sep, g[i][j]);
      sep = " ";
    }
    std::printf("\n");
  }
}

// eof

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

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

int main()
{
	int n;
	cin >> n;
	FOR(i, n)
	{
		int m,u;
		cin >> u >> m;
		FOR(j, m)
		{
			int l;
			cin >> l;
			G[u-1][l-1] = 1;
		}
	}
	FOR(i, n)
	{
		FOR(j, n)
		{
			cout << G[i][j];
			if (j != n - 1)cout << " ";
		}
		cout << endl;
	}
	return 0;
}