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>
#define MAX 100
using namespace std;

int G[MAX][MAX];

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

void input(int n) {
	int m, g, k;
	for (int i = 0; i < n; i++) {
		cin >> m >> k;
		--m;
		for (int j = 0; j < k; j++) {
			cin >> g;
			--g;
			G[m][g] = 1;
		}
	}
}

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

int main() {
	int size;
	cin >> size;
	arrayInit(size);
	input(size);
	output(size);
	return 0;
}

C++: #include<stdio.h>

#define MAX 107

int gragh [MAX][MAX];

int v[MAX];

int main(){
  int n,i,j;
  int vertex,num;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){    
      gragh[i][j] = 0;
    }
  }
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&vertex,&num);
    for(j=1;j<=num;j++){
      scanf("%d",&v[j]);
      gragh[vertex][v[j]] = 1;
    }
  }

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



  return 0;
}

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

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

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

int n;
int k;
int m;

int main() {
  cin >> n;
  int V[n];

  // int型の2次元配列(3×4要素の)の宣言
  vector<vector<int>> A(n, vector<int>(n));

  for (int i=0; i<n; i++) {
    cin >> V[i];
    cin >> k;
    if (k==0) {
      continue;
    } else {
      for (int j =0; j<k; j++) {
        cin >> m;
        A[i][m-1] = 1;
      }
    }
  }

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



 
}

C++: // -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_11_A: Graph

#include <cstdio>
#include <cstring>

int main()
{
  unsigned int n;
  std::scanf("%u", &n);

  int g[n][n];
  std::memset(g, 0, sizeof(g));

  unsigned int u, k, v;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u %u", &u, &k);
    for (auto j = 0u; j < k; ++j) {
      std::scanf("%u", &v);
      g[u-1][v-1] = 1;
    }
  }

  for (auto i = 0u; i < n; ++i) {
    const char* sep = "";
    for (auto j = 0u; j < n; ++j) {
      std::printf("%s%d", sep, g[i][j]);
      sep = " ";
    }
    std::printf("\n");
  }
}

// eof

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

int main()
{
	int M[N][N];  
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			M[i][j] = 0;
		}
	}
	int n,u,k,v;
	cin >> n;
	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<iostream>
#define FOR(i,n) for(int i=0;(i)<(n);(i)++)
using namespace std;
int G[101][101] = {};

int main()
{
	int n;
	cin >> n;
	FOR(i, n)
	{
		int m,u;
		cin >> u >> m;
		FOR(j, m)
		{
			int l;
			cin >> l;
			G[u-1][l-1] = 1;
		}
	}
	FOR(i, n)
	{
		FOR(j, n)
		{
			cout << G[i][j];
			if (j != n - 1)cout << " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #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--;
    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<<" "<<flush;
      }
      cout<<M[i][j]<<flush;
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
static const int N = 100;

int main(){
    int n, u, k, v;
    int M[N][N];
    
    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 <cstdio>

int main(void) {
    int n, u, k, v, i, j;
    scanf("%d", &n);
    int m[n+1][n+1];

    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            m[i][j] = 0;

    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            m[u][v] = 1;
        }
    }

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

    return 0;
}

C++: #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--;
		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;
}