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;
int main(){
  int graph[100][100]={},n,u,k,v;
  cin>>n;
  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){
      if(j) cout<<" ";
      cout<<graph[i][j];
    }
    cout<<endl;
  }
  return 0;
}

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

void solve()
{
    using namespace std;

    int n;
    cin >> n;

    vector<vector<bool>> edges(n, vector<bool>(n));

    for (int i = 0; i < n; ++i)
    {
        int u, k;
        cin >> u >> k;

        for (int j = 0; j < k; ++j)
        {
            int v;
            cin >> v;
            edges[u - 1][v - 1] = true;
        }
    }

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

int main()
{
    solve();
    return 0;
}

C++: /*  2019 6/23
    A Graph
*/

#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--;  // 0 origin

        for (int j = 0; j < k; ++j) {
            cin >> v;
            v--;

            M[u][v] = 1;
        }
    }

    // output
    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>
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) {
            cout << M[l][i] << " ";
        }
        cout << endl;
    }

    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
int main(){
	int n;
	int a, b;
	int A[101];
	int **arr = NULL;
	scanf("%d", &n);	
	arr = new int*[n];
	for (int i = 0; i < n; i++){
		arr[i] = new int[n];
	}
	for (int i = 0; i < n; i++){		
		scanf("%d%d", &a, &b);
		for (int j = 0; j < b; j++){
			scanf("%d",&A[j]);
			arr[a-1][A[j]-1] = 1;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (j == n - 1){
				if (arr[i][j] == 1){
					printf("1");
				}
				else {
					printf("0");
				}
			}
			else {
				if (arr[i][j] == 1){
					printf("1 ");
				}
				else {
					printf("0 ");
				}
			}
		}
		printf("\n");
	}
	for (int i = 0; i < n; i++){
		delete[](arr[i]);
	}
	delete[](arr);
	return 0;
}

C++: #include <iostream>
#define N 100

int v[N + 1][N + 1];

int main()
{
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            v[i][j] = 0;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        int u, k;
        std::cin >> u >> k;
        for (int j = 0; j < k; ++j)
        {
            int t;
            std::cin >> t;
            v[u][t] = 1;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (j > 1)
            {
                std::cout<<' ';
            }
            std::cout << v[i][j];
        }
        std::cout << "\n";
    }
}

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

int main(){

  int n,k,v,u;
  cin>>n;

  double V[n][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>>v;
      V[u-1][v-1]=1;
    }


  }

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

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                if(vec[i][k]==j) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }cout << endl;
}

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

void adjacency_list(int n, vector<vector<int>>& a)
{
	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;
			a[u][--v] = 1;
		}
	}
}

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	adjacency_list(n, a);

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