Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			fmt.Printf(" %d", Adj[i][j])
			if j == n-1 {
				fmt.Println()
			}
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
bool A[105][105];
int main()
{
	memset(A,0,sizeof(A));
	int n,v,u,du;
	cin>>n;
	getchar();
	for(int i=1;i<=n;i++){
		cin>>v>>du;
		while(du--)
			cin>>u,
			A[v][u] = 1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j==1) cout<<A[i][j];
			else cout<<' '<<A[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;
int main(){
  int n;
  int v[100][100]={};
  int u,k,a;
  cin >> n;
  rep(i,n){
    cin >> u >> k;
    u--;
    rep(j,k){
      cin >> a;
      a--;
      v[u][a]=1;
    }
  }
  rep(i,n){
    rep(j,n){
      if(j>0) cout << " " << v[i][j];
      else cout << v[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"
#define SP " "

int main() {

  int N;
  cin >> N;

  vector<vector<ll>> G(N, vector<ll>(N, 0));

  rep0(i, N) {
    int u, k;
    cin >> u >> k;
    rep0(j, k) {
      int v;
      cin >> v;
      G[i][v - 1] = 1;
    }
  }

  rep0(i, N) {
    rep0(j, N - 1) {
      cout << G[i][j] << SP;
    }
    cout << G[i][N - 1] << BR;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
#define int ll

int g[105][105];

signed main(void) {
  int n, u, k, v;

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

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

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

using namespace std;

struct Edge{
	int to;
};

vector<vector<int>> List_to_Mat(vector<vector<Edge>>& G){
	int V = G.size();
	vector<vector<int>> result;
	result = vector<vector<int>>(V, vector<int>(V, 0));

	for(int i = 0; i < V; i++){
		for(int j = 0; j < G[i].size(); j++){
			int v = G[i][j].to;
			result[i][v - 1] += 1;
		}
	}
	return result;
}


int main(void)
{
	int V;
	cin >> V;

	vector<vector<Edge>> AdjList(V);
	for(int i = 0; i < V; i++){
		int u, k;
		cin >> u >> k;
		for(int j = 0; j < k; j++){
			int v;
			cin >> v;
			AdjList[i].push_back(Edge{v});	
		}
	}

	vector<vector<int>> AdjMat = List_to_Mat(AdjList);
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			if(j != V - 1)
				cout << AdjMat[i][j] << " ";
			else
				cout << AdjMat[i][j] << endl;
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}



int main(){
    int n; cin >> n;
    vector<VI> A(n, VI(n, 0));
    REP(i, n){
        int u; cin >> u; --u;
        int k; cin >> k;
        REP(j, k){
            int v; cin >> v; --v;
            ++A[u][v];
        }
    }
    REP(i, n){
        REP(j, n){
            cout << (j ? " ": "") << A[i][j];
        }
        cout << "\n";
    }
    return 0;
}

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

int main()
{
    int M[N][N];
    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;
            M[u][v] = 1;
        }
    }

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

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

int main(){
	int n, u, k;
	vector<vector<int> > A;

	cin>>n;
	A.resize(n);
	for(int i=0;i<n;i++){
		A[i].resize(n);
	}

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			A[i][j] = 0;

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

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

	return 0;
}

C++: #include<stdio.h>

#define MAX 100

int G[MAX+1][MAX+1];

int main() {
    int n;
    scanf("%d", &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) {
        int u,k;
        scanf("%d %d", &u, &k);
        for (int j = 0; j < k; ++j) {
            int t;
            scanf("%d", &t);
            G[u][t] = 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            printf(" %d",G[i][j]);
        }
        printf("\n");
    }
}

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

int main() {
    int M[N][N];
    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;
}