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>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[100][100]={0};
	for(int l=0; l<n; l++){
		int v,k;
		cin>>v>>k;
		int u;
		for(int i=0; i<k; i++){
			cin>>u;
			a[v-1][u-1]=1;
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n-1; j++){
			cout<<a[i][j]<<" ";
		}
		cout<<a[i][n-1]<<endl;
	}
	return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int n;
typedef vector<vector<int> > AdjMatrix;
AdjMatrix graph;


int main()
{
    int u,k,v;
    cin >> n;
    graph = AdjMatrix(n, vector<int>(n, 0));
    REP(i,n){
        cin >> u >> k;
        REP(j,k){
            cin >> v;
            graph[u-1][v-1] = 1;
        }
    }

    REP(i, n){
        REP(j, n-1){
            cout << graph[i][j] << " ";
        }
        cout << graph[i][n-1] << endl;
    }
    return 0;
}

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

int main(){
    int n,k,u,v,M[LEN+1][LEN+1];
    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;
        for(int j=0;j<k;j++){
            cin>>v;
            M[u-1][v-1]=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>
using namespace std;

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

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

int main(){
    int n;
    cin>>n;
    vector<int> ans(101);
    for(int i=0;i<n;i++){
        ans[i]=0;
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        int y;
        cin>>y;
        int z;
        for(int j=0;j<y;j++){
            cin>>z;
            ans[z-1]=1;
        }
        for(int k=0;k<n;k++){
            cout<<ans[k]<<flush;
            if(k<n-1){
            	cout<<' '<<flush;
            }
        }
        for(int j=0;j<n;j++){
        ans[j]=0;
    }
    if(i<n){
    cout<<endl;
    }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,a,b,c;
  int G[200][200];

  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 >> a >> b;
    a--;
    for(int i = 0 ; i < b ; i++){
      cin >> c;
      c--;
      G[a][c] = 1;
    }
  }
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      if(j == 0)cout << G[i][j];
      else cout <<" "<< G[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<vector<int>>adj(n, vector<int>(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++) {
			if (j == 0) {
				cout << adj[i][j];
			}
			else {
				cout << " " << adj[i][j];
			}

		}
		cout << endl;
	}

}

C++: #include<iostream>
using namespace std;
int v[101][101] = { 0 };
int main() {
	int n; cin >> n;
	int u, k;
	for (int i = 1; i <= n;i++) {
		cin >> u >> k;
		for (int j = 0; j < k;j++) {
			int t; cin >> t;
			v[u][t] = 1;
		}
	}
	for (int i = 1; i <= n;i++) {
		for (int j = 1; j <= n;j++) {
			if (j != n) {
				cout << v[i][j] << ' ';
			}else{
				cout << v[i][j] << endl;
			}
		}
	}
}

C++: #include <iostream>
using namespace std;
int K[100][100];

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

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

template<typename InputIterator> constexpr std::string join(InputIterator first, InputIterator last, const std::string &sep) {
  if (first == last) return "";
  std::stringstream ss;
  ss << *(first++);
  for_each(first, last, [&](auto &x) { ss << sep << x; });
  return ss.str();
}

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}

  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }

  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }

  const Edges &operator[](const int &i) const { return g[i]; }

  Graph toRootedTree(int r);
  std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const int &src, const int &inf);
  Matrix warshallFloyd(const int &inf);
  std::pair<Weight, Edges> prim(const int &r);
  template<typename UnionFind> std::pair<Weight, Edges> kruskal();
  Weight solveTSP(const int &inf);
};

main {
  int n;
  cin >> n;
  Graph g(n);
  rep(_, n) {
    int u, k;
    cin >> u >> k;
    while (k--) {
      int v;
      cin >> v;
      g.addArc(u - 1, v - 1);
    }
  }
  Matrix d(n, Array(n, 0));
  rep(i, n) for (auto &e : g[i]) d[e.src][e.dst] = 1;
  for (auto &r : d) cout << join(all(r), " ") << endl;
}