Go: package main

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	n := nextInt()
	v := make([][]int, n)
	for i := 0; i < n; i++ {
		u := nextInt()
		k := nextInt()
		for j := 0; j < k; j++ {
			v[u-1] = append(v[u-1], nextInt())
		}
	}

	for _, vvs := range v {
		for j := 1; j <= n; j++ {
			if j > 1 {
				fmt.Fprint(w, " ")
			}
			p := sort.SearchInts(vvs, j)
			if p < len(vvs) && vvs[p] == j {
				fmt.Fprint(w, 1)
			} else {
				fmt.Fprint(w, 0)
			}
		}
		fmt.Fprintln(w)
	}

	w.Flush()
}

C++: #include<iostream>
using namespace std;
int main()
{
  int n,u,k,v,**M;
  cin>>n;
  M=new int*[n];
  for(int i=0;i<n;i++)
    {
      M[i]=new int[n];
      for(int j=0;j<n;j++)
	M[i][j]=0;
    }
  int count=0;
  while(count<n)
    {
      count++;
      cin>>u>>k;
      for(int i=0;i<k;i++)
	{
	  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];
    cout<<endl;
  }
}

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

using namespace std;

int main(){
  int n, u, k;
  cin >> n;

  vector<vector<int> > mtx(n);
  for(int i=0; i<n; i++)
    mtx[i].resize(n);


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

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

  return 0;
}

C++: #include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pll = pair<LL, LL>;
using vi = vector<int>;
using vd = vector<double>;
using vvi = vector<vi>;
using vll = vector<LL>;

//==============================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	vvi M(n + 1, vi(n + 1));

	int u, k, v;
	REP3(i, 1, n) {
		cin >> u >> k;
		REP3(j, 1, k) {
			cin >> v;
			M[u][v] = 1;
		}
	}

	REP3(i, 1, n) {
		REP3(j, 1, n) {
			if (j != 1) cout << " ";
			cout << M[i][j];
		}
		cout << "\n";
	}
	return 0;
}

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

struct noo{
  int yoko;
  int tate;
  int nn[];
};

noo t[1000000];
int n;
int k;


int main(){
  int adj[n+10][n+10];
  int num;
  cin>>n;
  int rin[n+1];
  int i=0,j=0;
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    cin>>num>>k;
    for(j=0;j<k;j++){
      cin>>rin[j];
      adj[num][rin[j]]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1)cout<<" ";
      cout<<adj[i][j];
    }
    cout<<endl;
  }
  return 0;
}

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

const int MAX = 105;
int m[MAX][MAX];

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

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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector< vector<int> > G(n, vector<int>(n, 0));
	for(int i = 0; i < n; ++i) {
		int u, k, v;
		cin >> u >> k;
		u--;
		
		for(int j = 0; j < k; ++j) {
			cin >> v;
			v--;
			G[u][v] = 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;

void fnInput(vector<vector<int>>& rvvnAdjcy)
{
  int nxSiz;
  cin >> nxSiz;

  rvvnAdjcy.resize(nxSiz + 1, vector<int>(nxSiz + 1, 0));
  for (int i = 0; i < nxSiz; i++)
  {
    int nx, nySiz;
    cin >> nx >> nySiz;
    for (int j = 0; j < nySiz; j++)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
}

void fnResult(const vector<vector<int>>& cnrvvnAdjcy)
{
  for (int i = 1; i < cnrvvnAdjcy.size(); i++)
  {
    for (int j = 1; j < cnrvvnAdjcy[i].size(); j++)
    {
      if (j != 1) cout << " ";
      cout << cnrvvnAdjcy[i][j];
    }
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;

  fnInput(vvnAdjcy);
  fnResult(vvnAdjcy);

  return 0;
}

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<n; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=n)
        cout << " ";
      }

      cout << endl;
    }
  }

C++: #include<iostream>

using namespace std;

static const int N = 100;

int main() {
  int M[N][N];

  int n;
  cin >> n;

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

  int u, k, v;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--; // to 0 origin
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--; // to 0 origin
      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>
#include<vector>
using namespace std;

int main()
{
  int n;
  int g[105][105];
  
  cin >> n;

  for(int i = 0; i < n; i++){
    int u, k;
    cin >> u >> k;

    for(int j = 0; j < n; j++) g[u-1][j] = 0;

    for(int j = 0; j < k; j++){
      int v;
      cin >> v;

      g[u-1][v-1] = 1;
      
    }

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

    cout << endl;
    
  }

  return 0;

}