Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;

int main() {
  cin >>N;
  vector<vector<bool>> A(N, vector<bool>(N, 0));
  rep(i, N){
    int u,k; cin >>u >>k; u--;
    rep(j, k){
      int x; cin >>x; x--; A[u][x] = 1;
    }
  }
  rep(i, N){
    rep(j, N){
      cout <<A[i][j];
      if (j == N-1) cout <<endl;
      else cout <<" ";
    }
  }
}

C++: #include<iostream>
using namespace std;
int main()
{
    int hh[108][108];
    int n,m,u,v;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            hh[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cin>>u>>m;
        for(int j=1;j<=m;j++)
        {
            cin>>v; hh[u][v]=1;
        }


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

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;
    }
}