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++: #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)
            cout << M[l][i] << " ";
        }
        if (l != n)
        cout << endl;
    }

    return 0;
}

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

int g[100][100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, u, k, v;
    int i, j;
    cin>>n;
    for(i=0; i<n; i++) {
        cin>>u>>k;
        for(j=0; j<k; j++) {
            cin>>v;
            g[u-1][v-1]=1;
        }
    }
    for(i=0; i<n; i++) {
        cout<<g[i][0];
        for(j=1; j<n; j++) {
            cout<<' '<<g[i][j];
        }
        cout<<'\n';
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n; cin >> n;
  //adjacent matrix expression
  int a[n+1][n+1];
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      a[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    int u; cin >> u;
    int k; cin >> k;
    for(int i=0;i<k;i++){
      int v; cin >> v;
      a[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n-1;j++){
      cout << a[i][j] << " ";
    }
    cout << a[i][n] << endl;
  }
}

C++: #include<vector>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<vector<int>>v(n);
	for (int i = 0; i < n; i++)
	{
		int u;
		cin >> u;
		v[i].push_back(u);
		int k;
		cin >> k;
		v[i].push_back(k);
		for (int j = 0; j < k; j++)
		{
			int number;
			cin >> number;
			v[i].push_back(number);
		}
	}
	vector <vector<int>>answer(n, vector<int>(n));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			answer[i][j] = 0;
		}

	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < v[i].size()-2; j++)
		{
			answer[v[i][0]-1][v[i][2 + j]-1 ]= 1;
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cout << answer[i][j];
		}
		cout << endl;
	}
}
/*
1 2 2 4
2 1 4
3 0
4 1 3


*/

C++: #include<iostream>
#include<cstdio>
#define N 101
using namespace std;

int main(){

  int n,n2,data,u;
  int g[N][N]; 
 //load n
  cin >>n;

  //initialize
  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++){
    scanf("%d%d",&u,&n2);
    for(int j=0;j<n2;j++){
      scanf("%d",&data);
      g[u][data]=1;
    }
  }

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

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
  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[i][j]=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;
static const int N=100;

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

  cin>>n;

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

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

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

  return 0;
}

C++: #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++){
            std::cout<<A[i][j]<<" ";
        }
        std::cout<<"\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N, vector<int>(N, 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;
            G[u-1][v-1]++;
        }
    }
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << G[i][j] << ((j+1==N)?"\n":" ");
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int V;
	cin >> V;
	vector <vector <bool>> adj(V, vector <bool> (V, 0));
	rep(V, i) {
		int u, k;
		cin >> u >> k;
		u--;
		rep(k, j) {
			int n;
			cin >> n;
			n--;
			adj[u][n] = 1;
		}
	}
	rep(V, i) rep(V, j) {
		cout << adj[i][j] << (j == V-1 ? '\n' : ' ');
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> edges[n];
	int u,k,v;
	for (int i = 0; i < n; ++i)
	{
		cin >> u >> k;

		for (int j = 0; j < k; ++j)
		{
			cin >> v;
			edges[i].push_back(v-1);
		}
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (j != 0)
			{
				cout << " ";
			}

			bool flag = false;

			for (int k = 0; k < edges[i].size(); ++k)
			{
				if (edges[i][k] == j)
				{
					flag = true;
				}
			}
			if (flag)
			{
				cout << "1";
			}
			else
			{
				cout << "0";
			}
		}
		cout << endl;
	}
	return 0;
}