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<stdio.h>
using namespace std;
static const int N = 100;
int main() {
    
    int n, u, k, v;
    int M[N][N];
    
    cin >> n;
    
    for ( i = 0; i < n; i++ ){
        for ( j = 0; j < n; j++ )
            M[i][j] = 0;
    }
    
    for ( i = 0; i < n; i++ ){
        cin >> u >> k;
        u--;
        for ( j = 0; j < k; j++ ){
            cin >> v;
            v--;
            M[i][j] = 1;
        }
    }
    
    for ( i = 0; i < n; i++ ){
        for ( j = 0; j < n; j++ ){
            if ( j )cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
using namespace std;
int  v[102][101], n;
int main() {
	int u, k, s;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			v[u][s] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j > 1) cout << " ";
			cout << v[i][j];
		}
		cout << endl;
	}	return 0;
}

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

#define MAX 100
int main() {
	int n = 0;
	scanf("%d", &n);
	int M[MAX][MAX] = { 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 = 0;
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

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

}

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

int main(){
	int n,deg; cin>>n;
	int **vertex,**matrix;
	vertex = new int*[n]; for(int i=0;i<n;i++) vertex[i] = new int[n+1];
	matrix = new int*[n]; for(int i=0;i<n;i++) matrix[i] = new int[n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			matrix[i][j] = 0;
	}
	
	for(int i=0;i<n;i++){
		cin>>vertex[i][0];
		cin>>deg;
		for(int j=1;j<=deg;j++){
			cin>>vertex[i][j];
			matrix[vertex[i][0]-1][vertex[i][j]-1] = 1;
		}
	}

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

	for(int i=0;i<n;i++) delete [] vertex[i]; delete [] vertex;
	for(int i=0;i<n;i++) delete [] matrix[i]; delete [] matrix;
}

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

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

  vector<int> c(n);
  vector<vector<int>> M(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    int node;
    int d;
    cin >> node >> d;
    node--;

    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      M[i][tmp] = 1;
    }
  }

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

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

int n;
int M[101][101];
int main() {
    cin >> n;

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

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

    return 0;
}

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

int g[100][100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, u, k, v;
    int i, j;
    cin>>n;
    for(i=0; i<n; i++) {
        cin>>u>>k;
        for(j=0; j<k; j++) {
            cin>>v;
            g[u-1][v-1]=1;
        }
    }
    for(i=0; i<n; i++) {
        cout<<g[i][0];
        for(j=1; j<n; j++) {
            cout<<' '<<g[i][j];
        }
        cout<<'\n';
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n; cin >> n;
  //adjacent matrix expression
  int a[n+1][n+1];
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      a[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    int u; cin >> u;
    int k; cin >> k;
    for(int i=0;i<k;i++){
      int v; cin >> v;
      a[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n-1;j++){
      cout << a[i][j] << " ";
    }
    cout << a[i][n] << endl;
  }
}

C++: #include<vector>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<vector<int>>v(n);
	for (int i = 0; i < n; i++)
	{
		int u;
		cin >> u;
		v[i].push_back(u);
		int k;
		cin >> k;
		v[i].push_back(k);
		for (int j = 0; j < k; j++)
		{
			int number;
			cin >> number;
			v[i].push_back(number);
		}
	}
	vector <vector<int>>answer(n, vector<int>(n));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			answer[i][j] = 0;
		}

	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < v[i].size()-2; j++)
		{
			answer[v[i][0]-1][v[i][2 + j]-1 ]= 1;
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cout << answer[i][j];
		}
		cout << endl;
	}
}
/*
1 2 2 4
2 1 4
3 0
4 1 3


*/

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

int main(){

  int n,n2,data,u;
  int g[N][N]; 
 //load n
  cin >>n;

  //initialize
  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++){
    scanf("%d%d",&u,&n2);
    for(int j=0;j<n2;j++){
      scanf("%d",&data);
      g[u][data]=1;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      printf("%d",g[i][j]);
      if(j!=n)printf(" ");
    }
    printf("\n");
  }

  return 0;
}