Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

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

int main() {
	int n,u,k,v;
	int i,j;
	vector<vector<int> > V;
	scanf("%d",&n);
	V.resize(n);
	for(i=0; i<n; ++i) {
		V[i].resize(n);
		for(j=0; j<n; ++j) {
			V[i][j]=0;
		}
	}
	for(i=0; i<n; ++i) {
		scanf("%d%d",&u,&k);
		for(j=0; j<k; ++j) {
			scanf("%d",&v);
			V[u-1][v-1]=1;
		}
	}
	for(i=0; i<n; ++i) {
		for(j=0; j<n-1; ++j) {
			printf("%d ",V[i][j]);
		}
		printf("%d\n",V[i][n-1]);
	}
	return 0;
}

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

using namespace std;

class Vertex
{
public:
    int number_of_edges;
    vector<int> edges;
};

int main()
{
    int n;
    cin >> n;

    vector<Vertex> adjacency_list(n);
    for (int i = 0; i < n; ++i) {
        int index;
        cin >> index >> adjacency_list[i].number_of_edges;

        adjacency_list[i].edges.resize(adjacency_list[i].number_of_edges);
        for (int j = 0; j < adjacency_list[i].number_of_edges; ++j)
            cin >> adjacency_list[i].edges[j];
    }

    vector<vector<int>> adjacency_matrix(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < adjacency_list[i].number_of_edges; ++j)
            adjacency_matrix[i][adjacency_list[i].edges[j] - 1] = 1;
    }

    for (int i = 0; i < n; ++i) {
        cout << adjacency_matrix[i][0];
        for (int j = 1; j < n; ++j)
            cout << ' ' << adjacency_matrix[i][j];
        cout << '\n';
    }
}

C++: #include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define INFTY (1<<30)
#define MAX 100000000

using namespace std;

int main() {
	int n, m[101][101] = {};
	cin >> n;
	for( int i = 1; i <= n; i++) {
		int u, k;
		cin >> u >> k;
		for( int j = 1; j <= k; j++) {
			int v;
			cin >> v;
			m[i][v] = 1;
		}
	}
	for( int i = 1; i <= n; i++) {
		for( int j = 1; j <= n; j++) {
			if( j < n) cout << m[i][j] << ' ';
			else cout << m[i][j]
		}
		cout << endl;
	}

    return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> mat(n, std::vector<int>(n, 0));
    
    for (int i = 0; i < n; i++){
        int u, k;
        std::cin >> u >> k;
        while(k--){
            int a;
            std::cin >> a;
            mat[u - 1][a - 1] = 1;
        }
    }
    
    // output
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            std::cout << mat[i][j];
            if (j != n - 1) std::cout << " ";
        }
        std::cout << std::endl;
    }
}

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] << ' ';
		if (j == V-1) cout << endl;
	}
}

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

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


static const int N=100;

int main()
{
    int M[N][N];//0 origin Adjacency matrix
    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--; //0 origin
        for(int j = 0; j < k; j++)
        {
            cin>>v;
            v--; //0 origin
            M[u][v]=1;//uとvの間に辺を張る
        }
    }


    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 <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef long long ll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define INF 10000000000 //10^10
#define PI 3.141592

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>
using namespace std;

static const int N = 100;

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

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
vector<int> adj[100];
int res[105][105] = {0};

int main() {
    int n; cin >> n;
    REP(i, n){
        int u, k;
        cin >> u >> k;
        REP(j, k) {
            int tmp;
            cin >> tmp;
            res[u][tmp] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n ; j++)
            cout << res[i][j] << " ";
        cout << res[i][n] << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

const int MAX = 100;
static int u[MAX][MAX];


int main() {


	int n, uid, ap, tmp;
	cin >> n;


	for (int i = 0;i < n;i++) {
		cin >> uid >> ap;
		for (int k = 0;k < ap;k++) {
			cin >> tmp;
			u[uid - 1][tmp - 1] = 1;
		}
	}

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