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 <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;
static const int N=100;

int main()
{
    int n,k,v,u,j,i;
    int Adj[N+1][N+1]={0};

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>u>>k;
        for(j=0;j<k;j++){
            cin>>v;
            Adj[u][v]=1;
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(j-1) cout<<" ";
            cout << Adj[i][j];
        }
        cout<<endl;
    }
    return 0;
}

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

int main(void){
  int m, a[100][100];
  int b[100][100]={0};

  cin >> m;

  for(int i=0; i<m; i++){
    cin >> a[i][0];
    cin >> a[i][1];

    for(int j=2; j<a[i][1]+2; j++){
      cin >> a[i][j];
      b[i][ a[i][j]-1 ] = 1;
    }
  }

  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){
      cout << b[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
static const int N = 100;

int main(){
    int M[N][N];
    int n, u, k, v;

    scanf("%d",&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 ){
        scanf("%d %d",&u,&k);
        u--;
        for( int j = 0; j < k; ++j ){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;
        }
    }

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

    return 0;
}

C++: #include<iostream>
using namespace std;
static const int N=100;

int main(){
  int MA[N][N];
  int n, u, k, v;

  cin >> n;

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

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

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

  return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

// graph
// adjacent list
vector<vector<int>> G; 
// adjacent matrix
const int MAX_N = 100;
int GM[MAX_N][MAX_N];

int main(){
    // input 
    int n; cin >> n;
    G.resize(n);
    rep(i, n){
        int from, edgeNum, to;
        cin >> from >> edgeNum;
        G[from-1].resize(edgeNum);
        rep(j, edgeNum){
            cin >> G[from-1][j];
        }
    }

    // output adjacent matrix
    rep(u, n){
        rep(i, G[u].size()){
            GM[u][G[u][i]-1] = 1; 
        }
    }
    rep(i, n)
        rep(j, n)
            cout << GM[i][j] << (j<n-1? " ": "\n");
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <string>
#include <climits>
using namespace std;

#define MAX_N 101


int main()
{
    vector<vector<int> > A(MAX_N, vector<int>(MAX_N, 0));
    int i, k, u, v, n;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> u >> k;
        while (k--) {
            cin >> v;
            A[u][v] += 1;
        }
    }
    for (i = 1; i <= n; i++) {
        for (k = 1; k <= n; k++) {
            if (k > 1) cout << " ";
            cout << A[i][k];
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
        int N;
        cin >> N;
        int a[110][110]={{0}};
        for(int i=0; i<N; i++){
                int v,n;
                cin >> v;
                cin >> n;
                for(int j=0; j<n; j++){
                        int V;
                        cin >> V;
                        a[v-1][V-1]=1;
                }
        }
        for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                        cout << a[i][j];
                }
                cout << endl;
        }
}

C++: #define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100
//#define MAX_ 1000
int main(void)
{
	int G[MAX][MAX] = { false };
	int n, u, k, v;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d", &u, &k);
		for (int j = 0; j < k; ++j) {
			scanf_s("%d", &v);
			G[u - 1][v - 1] = true;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (j != 0) printf(" ");
			printf("%d", G[i][j]);
		}
		if (i != n - 1) printf("\n");
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int>> graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(n);
    }
    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++){
        scanf("%d",&u);
        scanf("%d",&k);
        int value;
        for(int j=0;j<k;j++){
            scanf("%d",&value);
            graph[u-1][value-1]=1;
        }
    }

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

    return 0;
}