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;
const int MAX_N = 100;

int main() {
  int a[MAX_N+1][MAX_N+1];
  int n; cin >> n;

  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, k; cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int t; cin >> t;
      a[u][t] = 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 <stdio.h>
#define N 102

int main(){

  int u,k,i,j,v,n;
  int a[N][N];
 
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }
  
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      if(a[i][j]==NULL)a[i][j]=0;
    }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][n]);
  }

  return 0;

}

C++: #include<iostream>
using namespace std;
int main()
{
	int n, m, o, k, A[101][101] = {};
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> o >> k;
		o--;
		for (int j = 0; j < k; j++)
		{
			cin >> m;
			m--;
			A[o][m] = 1;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (j)cout << " ";
			cout << A[i][j];
		}
		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<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;
}

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

int main(){
	int n,m,l,i,j,p;
	cin >> n;
	int f[101][101];
	for ( i = 0; i < n; i++){
		cin >> m;
		cin >> p;
		for ( j = 0; j < p; j++){
			cin >> l;
			f[m-1][l-1] = 1;
		}
	}
	for ( i = 0; i < n; i++){
		for ( j = 0; j < n-1; j++){
			cout << f[i][j] << " ";
		}
		cout << f[i][n-1] << endl;
	}
}

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

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

    std::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++) {
        std::cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            std::cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;
static const int N = 100;

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

	std::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)
	{
		std::cin >> u >> k;
		u--;

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

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

	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
    int A[150][150];
    int n1,n2,a,b;
    cin >> n1;
    for (int i = 0; i < n1; i++){
        cin >> a;
        cin >> n2;
        for (int j = 0; j < n2; j++){
            cin >> b;
            A[a-1][b-1] = 1;
        }
    }
    for (int i = 0; i < n1; i++){
        for (int j = 0; j < n1; j++){
            cout << A[i][j];
            if (j == n1 - 1){
                cout << endl;
            }
            else {
                cout << " ";
            }
        }
    }
}

C++: #include<stdio.h>
#include<stdlib.h>

#pragma warning (disable:4996)

int main() {
	int a1[150][150] = { 0 };
	int a = 0,b=0,c=0,d=0;
	scanf("%d", &a);
	
	for (int i = 0; i < a; i++) {
		scanf("%d", &b);
		scanf("%d", &c);
		if (c > 0) {
			for (int j = 0; j < c; j++) {
				scanf("%d", &d);
				a1[b - 1][d - 1] = 1;
			}
		}
		if (c == 0) {
			for (int q = 2; q < a; q++) {
				a1[i][q] = 0;
			}
		}
	}
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < a; j++) {
			printf("%d ", a1[i][j]);
		}
		printf("\n");
	}

	return 0;
}