Go: package main
import (
	"fmt"
	"bufio"
	"os"
	"bytes"
	"strconv"
	"strings"
)

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num , _ :=  strconv.Atoi(scanner.Text())
	return num
}


func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	N := nextInt(scanner)
	var A [][]int = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = make([]int, N)
	}
	for i:=0; i<N; i++{
		idx := nextInt(scanner)
		cnt := nextInt(scanner)
		for j:=0; j<cnt; j++ {
			node := nextInt(scanner)
			A[idx-1][node-1] = 1
		}
	}
	var outBuffer bytes.Buffer
	for i:=0; i<N; i++ {
		outBuffer.WriteString(strings.TrimRight(fmt.Sprintf("%v",A[i])[1:], "]") + "\n")
	}
	fmt.Printf("%s", outBuffer.String())
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                if(vec[i][k]==j) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }cout << endl;
}

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;
}

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

int main(){
	int n,m,l,i,j,p;
	cin >> n;
	int f[101][101];
	for ( i = 0; i < n; i++){
		cin >> m;
		cin >> p;
		for ( j = 0; j < p; j++){
			cin >> l;
			f[m-1][l-1] = 1;
		}
	}
	for ( i = 0; i < n; i++){
		for ( j = 0; j < n-1; j++){
			cout << f[i][j] << " ";
		}
		cout << f[i][n-1] << endl;
	}
}

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

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

    std::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++) {
        std::cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            std::cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;
static const int N = 100;

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

	std::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)
	{
		std::cin >> u >> k;
		u--;

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

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

	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
    int A[150][150];
    int n1,n2,a,b;
    cin >> n1;
    for (int i = 0; i < n1; i++){
        cin >> a;
        cin >> n2;
        for (int j = 0; j < n2; j++){
            cin >> b;
            A[a-1][b-1] = 1;
        }
    }
    for (int i = 0; i < n1; i++){
        for (int j = 0; j < n1; j++){
            cout << A[i][j];
            if (j == n1 - 1){
                cout << endl;
            }
            else {
                cout << " ";
            }
        }
    }
}

C++: #include<stdio.h>
#include<stdlib.h>

#pragma warning (disable:4996)

int main() {
	int a1[150][150] = { 0 };
	int a = 0,b=0,c=0,d=0;
	scanf("%d", &a);
	
	for (int i = 0; i < a; i++) {
		scanf("%d", &b);
		scanf("%d", &c);
		if (c > 0) {
			for (int j = 0; j < c; j++) {
				scanf("%d", &d);
				a1[b - 1][d - 1] = 1;
			}
		}
		if (c == 0) {
			for (int q = 2; q < a; q++) {
				a1[i][q] = 0;
			}
		}
	}
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < a; j++) {
			printf("%d ", a1[i][j]);
		}
		printf("\n");
	}

	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,W;
int vx[]={1,0,-1,0};
int vy[]={0,1,0,-1};
int mt[102][102];
using namespace std;
void solve(){
    cin >> N ;
    int E,K;
    memset (mt,0,102*102);
    REP(i,N){
      cin >> E >> K;
      REP(j,K)
      {
        cin >> E;
        mt[i][E-1] = 1 ;
      }
    }
    REP(x,N){
      REP(y,N){
        cout << mt[x][y] << " ";
      }
      cout << endl;
    }
}
int main(){

    solve();
}

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; i<n; j++)
      m[i][j]=0;
  }

  for(int i=0; i<n; i++)
  {
    cin >> u >> k;
    u--;
    for(int j=0; i<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 << endl;
  }

  return 0;
}

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

int main(){
  int n, u, k, v;
  cin >> n;
  int A[n * n];

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

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

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

C++: #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n;
  cin >> n;
  vvi graph(n,vi(n,0));
  REP(i,n){
    int k;
    cin >> k >> k;
    REP(j,k){
      int tmp;
      cin >> tmp;
      graph[i][tmp-1]++;
    }
  }
  REP(i,n){
    cout << graph[i][0];
    FOR(j,1,n){
      cout << " " << graph[i][j];
    }
    cout << endl;
  }
}

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

int main()
{
	int n, k, u, v;
	cin >> n;
	// N * N matrix filled with 0
	vector< vector<int> > mat(n, vector<int>(n, 0));

	for(int i=0; i<n; i++){
		cin >> u >> k;
		// adjust 0 origen
		u--;
		for(int j=0; j<k; j++){
			cin >> v;
			//cout << "vertex: " << v << '\n';
			// adjust 0 origen
			v--;
			mat[u][v] += 1;
		}
		//cout << '\n';
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			printf("%d ", mat[i][j]);
		}
		cout << endl;
	}
	return 0;
}