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++: // ALDS1_11_A
#include <iostream>
#include <vector>
using namespace std;

int main(){
	int n, u, k;
	vector<vector<int> > A;

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

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

	return 0;
}

C++: #include<stdio.h>

#define MAX 100

int G[MAX+1][MAX+1];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            G[i][j] = 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        int u,k;
        scanf("%d %d", &u, &k);
        for (int j = 0; j < k; ++j) {
            int t;
            scanf("%d", &t);
            G[u][t] = 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            printf(" %d",G[i][j]);
        }
        printf("\n");
    }
}

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++: public class GraphAizu {
    //directed graph
    List<Integer> adg[];
    GraphAizu(int n){
        adg = new LinkedList[n+1];
        for(int i = 0; i<=n; i++){
            adg[i] = new LinkedList<>();
        }
    }
    void addEdge(int index, int vertex){
        adg[index].add(vertex);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        GraphAizu graph = new GraphAizu(n);
        for(int i = 0; i<n; i++){
            int index = in.nextInt();
            int m = in.nextInt();
            for(int j = 0; j<m; j++){
                int temp = in.nextInt();
                graph.addEdge(index,temp);
            }
        }
        //change to matrix
        int[][] matrix = new int[n+1][n+1];
        for(int i = 1; i<=n; i++){
            if(graph.adg[i].size()!=0) {
                for (int c : graph.adg[i]) {
                    matrix[i][c] = 1;
                }
            }
        }
        for(int i = 1; i<=n; i++){
            for(int j = 1; j<=n; j++){
                if(j!=n) System.out.print(matrix[i][j]+ " ");
                else System.out.print(matrix[i][j]);
            }
            System.out.println();
        }

    }
}

C++: #include <bits/stdc++.h>

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

int main()
{   
    /* 座席　（中央×後）*/
    //資料の説明通りにやってみたつもりです

    int n;
    cin >> n;
    vector<vector<int>> vc(n, vector<int>());

    REP(i, n) {
        int u, k, e;
        cin >> u >> k;

        REP(j, k) {
            cin >> e;
            vc.at(u-1).push_back(e-1);
        }
    }

    vector<vector<int>> A(n, vector<int> (n, 0));

    REP(i, n) {
        REP(j, vc.at(i).size()) {
            A.at(i).at(vc[i][j]) = 1;
        }
    }

    REP(i, n) {
        REP(j, n) {
            cout << A.at(i).at(j);
            if (j != n-1)   cout << " ";
        }
        cout << endl;
    }
}

C++: #include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<double, double> P;

void print_line(vector<bool> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<vector<bool>> matrix(n, vector<bool>(n, false));
    rep(i, n) {
        int j, k;
        cin >> j >> k;
        j--;
        rep(l, k) {
            int m;
            cin >> m;
            m--;
            matrix[j][m] = true;
        }
    }

    rep(i, n) print_line(matrix[i]);

}

C++: #include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int A[101][101];
	for (int i = 1; i <= n; i++) {//初期化
		for (int j = 1; j <= n; j++) {
			A[i][j] = 0;
		}
	}

	int u, k, v;
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			A[u][v] = 1;
		}
	}

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

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

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

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

int main()
{
    int t, max = 0;
    cin >> t;
    bool ar[110][110] = {0};
    for(int i = 0; i < t; i++)
    {
        //cout << i;
        int n, m;
        cin >> n >> m;
        if(n > max) max = n;
        //cout << n << m;
        for(int j = 0; j < m; j++)
        {
            int tmp;
            cin >> tmp;
            ar[n][tmp] = 1;
        }
    }
    for(int i = 1; i <= max; i++)
    {
        for(int j = 1;j <= max; j++)
        {
            cout << ar[i][j]  << " ";
        }
        cout << endl;
    }
}

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

int main(){
  int n,u,k;
  int ad;
  int arisutoteresu[200][200] = {0};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      arisutoteresu[u][ad] = 1;
    }
  }

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



  return 0;
}