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<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<vector<int>> a(n, vector<int>(n,0));
	rep(i,n){
		int from;
		int m;
		cin >> from >> m;
		from--;
		rep(j,m){
			int to;
			cin >> to;
			to--;
			a[from][to] = 1;
		}
	}

	rep(i,n){
		rep(j,n){
			if(j) cout << ' ';
			cout << a[i][j];
		}
		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;
  }
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;
int edge[103][103];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;
	REP(i,n){
		int v,t;cin>>v>>t;
		v--;
		while(t--){
			int u;
			cin>>u;
			u--;
			edge[v][u] = 1;
		}
	}
	REP(i,n){
		REP(j,n){
		if(j)cout << ' ';
			cout << edge[i][j];
		}
		cout << endl;
	}
  return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    int list[n][n] = {};
    std::vector<std::vector<int>> vertex;
    int tmp2;
    int num;
    for(int i=0;i<n;i++){
        std::vector<int> tmp;
        std::cin >> tmp2;
        std::cin >> num;
        for(int j=0;j<num;j++){
            std::cin >> tmp2;
            tmp.push_back(tmp2);
        }
        vertex.push_back(tmp);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<vertex[i].size();j++){
            if(vertex[i][j] > 0){
                list[i][vertex[i][j]-1] = 1;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            std::cout << list[i][j];
            if(j!=n-1){
                std::cout << " ";
            }
        }
        std::cout << "\n";
    }
}

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

int main()
{
	int n, A[100][100];
	cin>>n;


	for(int i=0;i<n;++i){

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

		int m,k; //k=number of adj
		cin>>m>>k;
		assert(m==i+1);

		for(int j=0;j<k;++j){
			int adj;
			cin>>adj;
			if(adj){
				A[i][adj-1]=1;
			}
		}
	
		for(int j=0;j<n;++j){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}

	return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<bool>> adjacent(n, vector<bool>(n,false));

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			adjacent[u-1][v - 1] = true;
		}
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << adjacent[i][j] << (j == n-1 ? "\n" : " ");
		}
	}

}

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

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

  vector<int> c(n);
  vector<vector<int>> M(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    int node;
    int d;
    cin >> node >> d;
    node--;

    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      M[i][tmp] = 1;
    }
  }

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

C++: #include <iostream>

using namespace std;

int main(){

  int n,u,k,v,graph[101][101]={{}};

  cin >> n ;

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

  for(int i = 1; i<= u; i++){
    for(int j = 1; j<= u; j++){
      cout << graph[i][j] << ' ' ; 
    }
    cout << endl;
  }


  return 0;
}

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

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

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

}

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


  }

C++: #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   vector<vector<int>> G(n, vector<int>(n));
   rep(i, 0, n) {
      int u, k;
      cin >> u >> k;
      u--;
      rep(j, 0, k) {
         int v;
         cin >> v;
         v--;
         G[u][v] = 1;
      }
   }
   rep(i, 0, n) rep(j, 0, n) printf("%d%c", G[i][j], j == n - 1 ? '\n' : ' ');
   return 0;
}

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

void fnInput(vector<vector<int>>& rvvnAdjcy)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvvnAdjcy.resize(nMaxSiz + 1, vector<int>(nMaxSiz + 1, 0));
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nx, nSecSiz;
    cin >> nx >> nSecSiz;
    for (int j = 0; j < nSecSiz; j++)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
}

void fnResult(const vector<vector<int>>& cnrvvnAdjcy)
{
  for (int i = 1; i < cnrvvnAdjcy.size(); i++)
  {
    for (int j = 1; j < cnrvvnAdjcy[i].size(); j++)
    {
      if (j != 1) cout << " ";
      cout << cnrvvnAdjcy[i][j];
    }
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;

  fnInput(vvnAdjcy);
  fnResult(vvnAdjcy);

  return 0;
}