Go: package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <vector <ll>> v(n, vector <ll> (n, 0));
  ll u, k;
  rep(i, n) {
    cin >> u >> k;
    rep(j, k) {
      ll a;
      cin >> a;
      v.at(u-1).at(a-1)++;
    }
  }
  rep(i, n) {
    rep(j, n) {
      if (j) {
        cout << ' ' << v.at(i).at(j);
      } else {
        cout << v.at(i).at(j);
      }
    }
    cout << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n][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++){
    int u,k,v;
    cin>>u>>k;
    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;
  }
}

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

int main(void){
  int m, a[100][100];
  int b[100][100];

  cin >> m;

  for(int i=0; i<m; i++){
    cin >> a[i][0];
    cin >> a[i][1];

    for(int j=2; j<a[i][1]+2; j++){
      cin >> a[i][j];
      b[i][ a[i][j]-1 ] = 1;
    }
  }

  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){
      if(j == m-1){
	cout << b[i][j];
      }else{
	cout << b[i][j] << " ";
      }
    }
    cout << "\n";
  }

  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int mat[N][N] = {};

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

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << mat[i][j];
            if (j != N - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
}

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

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

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<string, int>
#define fi				first
#define se				second

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 100;

bool G[MAX_N][MAX_N];

signed main() {
	fill( G[0], G[MAX_N], false );
	int n; cin >> n;
	REP( i, n ) {
		int v, k; cin >> v >> k;
		v--;
		REP( j, k ) {
			int u; cin >> u;
			u--;
			G[v][u] = true;
		}
	}

	REP( i, n ) {
		REP( j, n ) {
			if( !j ) cout << G[i][j];
			else	cout << " " << G[i][j];
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

bool adj[105][105];

int main()
{
	memset (adj, false, sizeof (adj ) );

	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	rep (i, n ){
		int v, k;
		cin >> v >> k;
		rep (j, k ){
			int u; cin >> u;
			adj[v][u] = true;
		} // end rep
	} // end rep
	
	for (int i = 1; i <= n; i++ )
		for (int j = 1; j <= n; j++ )
			cout << (adj[i][j] ? 1 : 0) << (j != n ? ' ' : '\n' );
	
	
	return 0;
}

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

const int MAX = 110;
int mat[MAX][MAX];

int main()
{
  int n; cin >> n;
  memset(mat, 0, sizeof(mat));
  for (int i = 0; i < n; i++) {
    int u, k; cin >> u >> k;
    u--;
    while(k--) {
      int v; cin >> v; v--;
      mat[u][v] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      cout << mat[i][j] << (j==n-1?'\n':' ');
  }
  return EXIT_SUCCESS;
}

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

int main() {
  int n;
  cin >> n;
  vector< vector<int> > a(n, vector<int>(n, 0));
  for(int i=0;i<n;i++) {
    int u,k;
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++) {
      int v;
      cin >> v;
      v--;
      a[u][v]++;
    }
  }
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      if(j) cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }
}

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] >> k[i];

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

      else
        cout << 0;

      if(j!=3)
        cout << " ";
      }
      cout << endl;
    }
  }