Go: package main

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

const N = 100

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var M [N][N]int
	for i := 0; i < n; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		u--
		for j := 0; j < k; j++ {
			sc.Scan()
			v, _ := strconv.Atoi(sc.Text())
			v--
			M[u][v] = 1
		}
	}

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				out.WriteString(" ")
			}
			out.WriteString(fmt.Sprintf("%d", M[i][j]))
		}
		out.WriteString("\n")
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}

C++: #include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int n;

int main(int argc, const char * argv[]) {
    
    /////////
    //write//
    /////////
    
    cin >> n;
    int arr[100][100];
    for(int i=0; i<100; i++){
        for(int j=0; j<100; j++){
            arr[i][j] = 0;
        }
    }
    
    for(int i=0; i<n; i++){
        int node, degree; cin >> node >> degree;
        for(int j=0; j<degree; j++){
            int tmp; cin >> tmp;
            arr[node-1][tmp-1] = 1;
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j)cout << " ";
            cout << arr[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

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




int main(){
  int n;
  cin >> n;
  vector<vector<int> > G(n, vector<int>(n,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;
      G[u-1][v-1] = 1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)  cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }
}

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

int main() {
  int n, u, k, v;
  cin >> n;

  vector<vector<int>> G(n, vector<int>(n, 0));
  
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--;
      G.at(u).at(v) = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) cout << ' ';
      cout << G.at(i).at(j);
    }
    cout << endl;
  }
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int h[1010];

int M[110][110];

signed main() {
	ios::sync_with_stdio(false);
	int i, n;
	cin >> n;
	rep(i, n) {
		int u, k;
		cin >> u >> k;
		int j;
		rep(j, k) {
			int v;
			cin >> v;
			M[u][v] = 1;
		}
	}

	rep(i, n) {
		int j;
		rep(j,n){
			if (j) cout << ' ';
			cout << M[i + 1][j + 1];
		}
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u,j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

C++: #include<iostream>

#define MAX 105

int main(){
  int n,u,k;
  int adj[MAX][MAX] = {{0}};
  int A[MAX][MAX] = {{0}};
  std::cin >> n;
  for(int i=1;i<=n;i++){
    std::cin >> u >> k;
    for(int j=1;j<=k;j++){
      std::cin >> adj[u][j];
    }
    adj[u][k+1] = -1;
  }
  //std::cout << "入力\n";

  for(int i=1;i<=n;i++){
    int j=1;
    while(adj[i][j] != -1){
      A[i][adj[i][j]] = 1;
      j++;
    }
    std::cout << A[i][1] ;
    for(j=2;j<=n;j++){
      std::cout << ' ' << A[i][j] ;
    }
    std::cout << '\n';
  }

  return 0;
}

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

int main(){
  int a,b,c,d,g[101][101]={0};
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b>>c;
    for(int j=0;j<c;j++){
      cin>>d;
      g[b][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout<<g[i][j];
      if(a-j>=1)cout<<" ";
    }
    cout<<endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int n; cin >> n;
    int mat[n][n];
    rep(i,n) rep(j,n) mat[i][j] = 0;
    rep(i, n){
        int u; cin >> u;
        int k; cin >> k;
        rep(j,k){
            int vj; cin >> vj;
            mat[u-1][vj-1] = 1;
        }
    }
    // 出力
    rep(i,n){
        rep(j,n){
            cout << mat[i][j];
            if(j != n-1) cout << " ";
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> matrix(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--;
            matrix[u][v] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << matrix[i][j];
            if (j != n - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

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

int ari;
int jigoku[102];
int u[102];
int v[102][102];
int ushi[102][102];
int main(){
  cin>>ari;
  for(int i=1;i<ari+1;i++){
    cin>>u[i]>>jigoku[u[i]];
      for(int j=1;j<jigoku[u[i]]+1;j++){
	cin>>v[u[i]][j];
      }
  }
  //for(int uma=1;uma<ari+1;uma++){cout<<u[uma];}
  for(int k=1;k<ari+1;k++){
    for(int l=1;l<jigoku[k]+1;l++){
      for(int m=1;m<ari+1;m++){
	//cout<<v[k][l];
	if(v[k][l]==u[m]){ushi[k][m]=1;}
	//cout<<ushi[k][m];
      }
    }
  }
    for(int k=1;k<ari+1;k++){
      for(int m=1;m<ari;m++){
	cout<<ushi[k][m]<<" ";
      }cout<<ushi[k][ari];
      cout<<endl;}
}