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<iostream>
using namespace std;

#define N 100

int main() {
  int i, j, n, u, k, v;
  int A[N+1][N+1];  

  cin >> n;
    
  
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      A[i][j] =  0;
    }
  }    

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

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

  return 0;
}

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

int main() {
   // freopen("in.txt", "r", stdin);

    int n, u, k, v;
    int graph[MAX][MAX];
    cin >> n;

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

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;    

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    bool graph[105][105]={false};
    int num,a,b;
    rep(i,n){
	cin>>a>>b;
	rep(j,b){
	    cin>>num;
	    graph[a][num]=true;
	}
    }
    reps(i,n){
	reps(j,n-1){
	    cout<<graph[i][j]<<" ";
	}
	cout<<graph[i][n]<<'\n';
    }
    
    return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int G[n][n];
  rep(i,n) memset(G[i], 0, sizeof(G[i]));
  int u, k;
  rep(i,n) {
    cin >> u >> k;
    rep(j,k) {
      int t;
      cin >> t;
      G[i][t-1] = 1;
    }
  }

  rep(i,n) {
    rep(j,n) printf("%d%c", G[i][j], (j==n-1 ? '\n' : ' '));
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector< vector<int> > g_matrix;
    g_matrix = vector< vector<int> >(n, vector<int>(n, 0));
    
    for(int i = 0; i < n; i++){
        int u, k;
        scanf("%d %d", &u, &k);
        u--;
        for(int j = 0; j < k; j++){
            int v;
            scanf("%d", &v);
            v--;
            g_matrix[u][v] = 1;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n - 1; j++){
            printf("%d ", g_matrix[i][j]);
        }
        printf("%d", g_matrix[i][n - 1]);
        printf("\n");
    }
    return 0;
}

C++: #include<iostream>
#include <cstdlib>
#include<list>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<stack>
#define MAX 101
using namespace std;
int main() {
	int n, a, k, d, data[MAX][MAX] = { 0,0 }; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> d;
			data[i][d - 1] = 1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (j)cout << " ";
			cout << data[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int n, u, k, v;
int Adj[MAX_N][MAX_N];

void initialize(){
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			Adj[i][j] = 0;
		}
	}
}

void check_adj(){
	Adj[u][v] = 1;
}

void print_adj(){
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cout << Adj[i][j];
			if(j == n - 1) cout << endl;
			else cout << " ";
		}
	}
}

int main(void){
	cin >> n;
	initialize();
	for(int i = 0; i < n; i++){
		cin >> u;
		u--;
		cin >> k;
		for(int j = 0; j < k; j++){
			cin >> v;
			v--;
			check_adj();
		}
	}
	print_adj();

	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int m[n+1][n+1]={0};
	for(int i=0;i<n;i++){
		int id, k;
		cin >> id >> k;
		for(int j=0;j<k;j++){
			int d;
			cin >> d;
			m[id][d]=1;
		}
	}
	
	for(int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if(j!=1) cout << " ";
			cout << m[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector< vector<int> > G(n, vector<int>(n));
    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--;
            G[u][v] = 1;
        }
    }

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

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

int main() {
    int n, u, k, tmp;
    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++) {
        cin >> u >> k;
        for (int j=0; j<k; j++) {
            cin >> tmp;
            M[u-1][tmp-1] = 1;
        }
    }

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cout << M[i][j];
            if (j<n-1) {
                cout << ' ';
            } else {
                cout << endl;
            }
        }
    }
    return 0;
}