Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

C++: #include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int g[101][101];
int main(){
  long ii,jj,kk;
  vector<int> a;

  memset(g,0,sizeof(g));
  int n;
  cin >> n;
  int v,vn,r;
  for(ii=0;ii<n;ii++){
    cin >> v;
    cin >> vn;
    for(jj=0;jj<vn;jj++){
      cin >> r;
      g[v][r] = 1;
    }
  }

  for(ii=1;ii<=n;ii++){
    for(jj=1;jj<=n;jj++){
      cout << g[ii][jj] ;
      if(jj!=n){
        cout << " ";
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
int fact(int n){
  int m;
  if (n == 0)
      return 1;
  m = fact(n - 1);    
  return n * m;       
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,u,k,node;
  cin>>n;
  vector<vector<int> > ma(n,vector<int>(n));
  rep(i,n){
      cin>>u>>k;
      rep(j,k){
	  cin>>node;
	  ma[u-1][node-1]=1;
      }
  }
  rep(i,n){
      rep(j,n){
	  cout<<ma[i][j]<<(j!=n-1 ? " " : "");
      }
      cout<<'\n';
  }
  return(0);
}

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

int main() {
	int m[100][100]={};
	int n,k,v,d;cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>d>>k;d--;
		for(int j=0;j<k;j++)
		{
			cin>>v;
			m[d][--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>
#include <vector>
using namespace std;

int main() {
    int num;
    cin >> num;
    vector<vector<int>> array(num, vector<int>(num, 0));
    for(int i=0; i<num; i++) {
        int index;
        int degree;
        cin >> index >> degree;
        for(int j=0; j<degree; j++) {
            int edge;
            cin >> edge;
            array.at(index-1).at(edge-1) = 1;
        }
    }

    for(int i=0; i<num; i++) {
        for(int j=0; j<num; j++) {
            if(j != 0) cout << " ";
            cout << array.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

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++: // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    Graph G(N, vector<int>(N, 0));
    rep(i, N){
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, k){
            int v;
            cin >> v;
            v--;
            G[u][v] = 1;
        }
    }

    rep(i, N){
        rep(j, N){
            if(j) cout << ' ';
            cout << G[i][j];
        }
        cout << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main() {
  int n,p,q,r;
  cin>>n;
  int a[100][100]={};
  for (int i=0;i<n;i++){
    cin>>q>>p;
    if (p!=0){
      for (int j=0;j<p;j++){
	cin>>r;
	a[i][r-1]=1;
      }
    }
  }
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      cout<<a[i][j];
      if (j!=n-1)cout<<" "; 
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <stdio.h>

#define N 100

int main(){
	int n;
	scanf("%d",&n);
	int A[N][N];
	int i;
	int v;
	int j;
	int p;
	int q;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			A[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		scanf("%d",&v);
		scanf("%d",&q);
		for(j=0;j<q;j++){
			scanf("%d",&p);
			A[v-1][p-1] = 1;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n-1;j++){
			printf("%d ",A[i][j]);
		}
		printf("%d\n",A[i][j]);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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