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>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define INFTY (1<<30)
#define MAX 100000000

using namespace std;

int main() {
	int n, m[101][101] = {};
	cin >> n;
	for( int i = 1; i <= n; i++) {
		int u, k;
		cin >> u >> k;
		for( int j = 1; j <= k; j++) {
			int v;
			cin >> v;
			m[i][v] = 1;
		}
	}
	for( int i = 1; i <= n; i++) {
		for( int j = 1; j <= n; j++) {
			if( j < n) cout << m[i][j] << ' ';
			else cout << m[i][j]
		}
		cout << endl;
	}

    return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> mat(n, std::vector<int>(n, 0));
    
    for (int i = 0; i < n; i++){
        int u, k;
        std::cin >> u >> k;
        while(k--){
            int a;
            std::cin >> a;
            mat[u - 1][a - 1] = 1;
        }
    }
    
    // output
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            std::cout << mat[i][j];
            if (j != n - 1) std::cout << " ";
        }
        std::cout << std::endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int V;
	cin >> V;
	vector <vector <bool>> adj(V, vector <bool> (V, 0));
	rep(V, i) {
		int u, k;
		cin >> u >> k;
		u--;
		rep(k, j) {
			int n;
			cin >> n;
			n--;
			adj[u][n] = 1;
		}
	}
	rep(V, i) rep(V, j) {
		cout << adj[i][j] << ' ';
		if (j == V-1) cout << endl;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}

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


static const int N=100;

int main()
{
    int M[N][N];//0 origin Adjacency matrix
    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--; //0 origin
        for(int j = 0; j < k; j++)
        {
            cin>>v;
            v--; //0 origin
            M[u][v]=1;//uとvの間に辺を張る
        }
    }


    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++: #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef long long ll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define INF 10000000000 //10^10
#define PI 3.141592

int main(){
    int n;
    cin >> n;
    vector<vint> A(n,vint(n,0));
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v;
            cin >> v;
            A[u-1][v-1]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout << A[i][j];
            if(j<n-1) cout << ' ';
        }
        cout << endl;
    }
}

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

static const int N = 100;

int main()
{
	int M[N][N];
	int n,u,v,k;
	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++: #include <bits/stdc++.h>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
vector<int> adj[100];
int res[105][105] = {0};

int main() {
    int n; cin >> n;
    REP(i, n){
        int u, k;
        cin >> u >> k;
        REP(j, k) {
            int tmp;
            cin >> tmp;
            res[u][tmp] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n ; j++)
            cout << res[i][j] << " ";
        cout << res[i][n] << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

const int MAX = 100;
static int u[MAX][MAX];


int main() {


	int n, uid, ap, tmp;
	cin >> n;


	for (int i = 0;i < n;i++) {
		cin >> uid >> ap;
		for (int k = 0;k < ap;k++) {
			cin >> tmp;
			u[uid - 1][tmp - 1] = 1;
		}
	}

	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++) {
			if (k > 0) cout << ' ';
			cout << u[i][k];
		}
		cout << endl;
	}
	return 0;
}

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

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