Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

C++: #include <iostream>
using namespace std;
int main(){
        int N;
        cin >> N;
        int lt[200][200]={0};
        for( int i=0 ; i<N ; i++ ){
                int x,y,n;
                cin >> x >> n;
                for(int l=0 ; l<n ; l++ ){
                        cin >> y;
                        lt[x-1][y-1]=1;
                }
        }
        for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                        cout<<lt[i][j];
                        if(j!=N-1)cout<<" ";
                }
                cout<<endl;
        }
        return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,k,a,u,V[200][200];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>k;
        for(int j=1;j<=k;j++){
            cin>>u;
            V[a][u]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j==1) cout<<V[i][1];
            else cout<<" "<<V[i][j];
        }
        cout<<endl;
    }
}

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

int main () {
    int n;
    cin >> n;
    int M[n][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++){
        int id, k;
        cin >> id >> k;
        for (int j = 0; j < k; j++){
            int tmp;
            cin >> tmp;
            M[i][tmp-1] = 1;
        }
    }
    for (int i = 0; i< n; i++){
        for (int j = 0; j < n; j++){
            if (j < n - 1){
                cout << M[i][j] << " ";
            } else {
                cout << M[i][j] << endl;
            }
            
        }
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

static const int N = 100;

int main(){
  int G[N][N];
  int u, v, k, n;

  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 >> u >> k;
     u--;
     for(int j = 0; j < k; j++){
       cin >> v;
     v--;
     G[u][v] = 1;
   }
}

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

   return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

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

    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int> > graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(n);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            graph[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
        int value;
        for(int j=0;j<k;j++){
            scanf("%d",&value);
            graph[u-1][value-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            printf("%d ",graph[i][j]);
        }
        printf("\n");
    }

    return 0;
}

C++: //16D8104001K 田中誠人 makoto0106 c++
#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
  std::vector<int>num;
  int n,k,tmp,x,size;

  std::cin>>n;
  
  for(int i=0;i<n;i++){
    std::cin>>tmp>>k;
    num.push_back(k);
    for(int j=0;j<k;j++){
      std::cin>>tmp;
      num.push_back(tmp);
      //std::cout<<tmp<<" ";
    }
  }
  size=num.size();
  /*
  for(int i=0;i<size;i++){
    std::cout<<num[i]<<" ";
  }
  */
  x=0;
  std::cout<<"\n";
  while(x<size){
    if(num[x]==0){
      for(int i=0;i<n;i++){
	std::cout<<"0 ";
      }
      x++;
    }else{
      x++;
      for(int i=0;i<n;i++){
      
	if(i+1==num[x]){
	  std::cout<<"1 ";
	  x++;
	}else{
	  std::cout<<"0 ";
	}
      }
    }
    std::cout<<"\n";
  }
  

  std::cout<<"\n";

  
  return 0;
}
/*実行結果
4
1 2 2 4
2 1 4
3 0
4 1 3

0 1 0 1 
0 0 0 1 
0 0 0 0 
0 0 1 0 

*/

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

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

	for (int i = 0; i < n; i++) {
		int vertex,jisu;
		cin >> vertex>>jisu;
		for (int j = 0; j < jisu; j++) {
			int to;
			cin >> to;
			graph[vertex-1][to-1] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (graph[i][j] != 1) graph[i][j] = 0;
			cout << graph[i][j];
			if (j < n - 1)cout << " ";
			else cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}

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

int main() {
	int n, u, k, v;
	cin >> n;
	vector<vector<bool>> am(n, vector<bool>(n));
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v;
			am[u - 1][v - 1] = true;
		}
	}
	for (vector<bool>& i : am) {
		cout << i[0];
		for (int j = 1; j < n; ++j) cout << ' ' << i[j];
		cout << endl;
	}
}

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

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

  int u[n],k;
  int a[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    cin>>u[i];
    cin>>k;
    for(int j=0;j<k;j++){
      int v;
      cin>>v;
      a[i][v-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]<<"\n";
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

void solve() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n,0));
    Rep(i, 1, n){
        ll u, k; cin >> u >> k;
        rep(i, 0, k){
            ll v; cin >> v;
            a[u-1][v-1] = 1;
        }
    }
    rep(i, 0, n){
        rep(j, 0, n){
            if(j) cout << " ";
            cout << a[i][j];
        }
        cout << "\n";
    }

    return;
}

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

    solve();
    return 0;
}

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


int main(int argc, char const *argv[]) {
  int n; // .. 100
  std::cin >> n;


  std::vector<std::vector<bool> > adj(n, std::vector<bool>(n));

  for(int q=0; q<n; ++q){
    int i_plus_1, k;
    std::cin >> i_plus_1;
    std::cin >> k;
    for(int p=0; p<k; ++p){
      int j_plus_1;
      std::cin >> j_plus_1;
      adj[i_plus_1-1][j_plus_1-1] = true;
    }
  }

  for(int i=0; i<n; ++i){
      for(int j=0; j<n; ++j){
        std::cout  <<  adj[i][j] << (j==n-1 ? "" : " "); 
      }
      std::cout << std::endl;
  }

  return 0;
}

C++: #include<iostream>
int main(){
  int n;
  std::cin>>n;
  int i,j;
  int u[n],k;
  int a[n][n];
  //行列の初期化
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      a[i][j]=0;
    }
  }
  
  for(i=0; i<n; i++){
    std::cin>>u[i];
    std::cin>>k;
    for(j=0; j<k; j++){
      int v;
      std::cin>>v;
      a[i][v-1]=1;
    }
  }
  for(i=0; i<n; i++){
    for(j=0; j<n-1; j++){
      std::cout<<a[i][j]<<" ";
    }
    std::cout<<a[i][n-1]<<"\n";
  }
}