Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

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

using namespace std;

int main(void){

  int graph[100][100];
  for( int i = 0 ; i < 100 ; i++ )
    for( int j = 0 ; j < 100 ; j++ )
      graph[i][j] = 0;

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

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

int n, u, k, v;
int g[101][101];

int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        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] << (j == n - 1 ? "\n" : " ");
        }
    }

    return 0;
}

C++: #define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100
//#define MAX_ 1000
int time = 0;
int main(void)
{
	int G[MAX][MAX] = { false };
	int n, u, k, v;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d", &u, &k);
		for (int j = 0; j < k; ++j) {
			scanf_s("%d", &v);
			G[u - 1][v - 1] = true;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (j != 0) printf(" ");
			printf("%d", G[i][j]);
		}
		if (i != n - 1) printf("\n");
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, k[102], v[101][102] = {0}, i, j, l, a;

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

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (k[i] == 0) {
        for (l = v[i][j - 1]; l < n - 1; l++) {
          cout << "0 ";
        }
        cout << "0\n";
        break;
      }
      else {
        if (v[i][j] != 0) {
          k[i]--;
          for (l = v[i][j - 1]; l < v[i][j] - 1; l++) {
            cout << "0 ";
          }
          if (v[i][j] == n) {
            cout << "1\n";
            break;
          }
          else {
            cout << "1 ";
          }
        }
      }
    }
  }

  return 0;
}

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

const static int N = 100;

int main() {
  int n, G[N][N];
  int v, m, k;
  
  cin >> n;

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

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

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

  return 0;    
}

C++: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> g(n, vector<int>(n));
  int u, k, v;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      g[u - 1][v - 1] = 1;
    }
  }
  debug(g);
  string ans = "";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans += to_string(g[i][j]) + " ";
    }
    ans.pop_back();
    ans += "\n";
  }
  cout << ans;
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define _USE_MATH_DEFINES // M_PI????????????????????????
#include<math.h>
#pragma warning(disable:4996)
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; // u??¨v?????????????????????
		}
	}

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

C++: #include <iostream>

constexpr int MAXN = 100;
int V[MAXN][MAXN];
int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int id, e_num;
        std::cin >> id >> e_num;
        for (int j = 0; j < e_num; j++) {
            int t;
            std::cin >> t;
            V[id - 1][t - 1] = 1;
        }
    }

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

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

int graph[101][101];
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int u,k,v; cin>>u>>k;
    for(int j=1;j<=k;j++){
      cin>>v;
      graph[u][v]=1;
    }
  }

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