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>
#include <vector>
using namespace std;

const long N = 100;

int main(){
	long n;
	cin >> n;
	long c[N + 1][N + 1];
	for (long i = 1; i <= n; i++){
		for (long j = 1; j <= n; j++){
			c[i][j] = 0;
		}
	}
	for (long i = 1; i <= n; i++){
		long u, k;
		cin >> u >> k;
		long m[N];
		for (long j = 1; j <= k; j++){
			cin >> m[j];
			c[u][m[j]] = 1;
		}
	}
	for (long i = 1; i <= n; i++){
		for (long j = 1; j <= n; j++){
			if (j - 1) cout << " ";
			cout << c[i][j];
		}
		cout << endl;
	}
}

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

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

  int mat[n][n];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      mat[i][j]=0;

  int u, k;
  cin >> u >> k;
  for(int i=0;i<k;i++){
    mat[u-1][k-1]=1;
  }

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

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

using namespace std;

int mat[110][110];

int main()
{

    int n;

    cin>>n;

    for(int i=0;i<n;i++)
    {
        int a,b;

        cin>>a>>b;

        for(int j=0;j<b;j++)
        {
            int c;

            cin>>c;

            mat[a][c]=1;
        }
    }

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


    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,lis[100][100]={};
  cin>>n;
  for(int c=0;c<n;c++){
    int u,k,v;
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v;
      lis[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<lis[i][j];
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <queue>
using namespace std;
struct dot{
	long long int k,p,l,r;
};
int main(int argc, char** argv) {
	int n;
	while(cin>>n){
		int d[n][n]={0};
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			a--;
			for(int j=0;j<b;j++){
				int c;
				cin>>c;
				d[i][c-1]=1;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<d[i][j];
				if(j<n-1)
					cout<<" ";
			}
			cout<<endl;
		}
			
				
	}
	return 0;
}

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]);
		}
		printf("\n");
	}
}

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

int n;
int ad_list[101][101];

void print(){
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            cout << ad_list[i][j];
            if(j==n)cout << "\n";
            else cout << " ";
        }
    }
}

int main(){
    cin  >> n;
    for(int i=1;i<n+1; i++){
        for(int j=1; j<n+1; j++){
            ad_list[i][j]=0
        }
    }
    int v,k, in;
    for(int i=1; i<n+1; i++){
        cin >> v >> k;
        for (int j=0;j<k;j++){
            cin >> in;
            ad_list[v][in]=1;
        }
    }
    print();
}

C++: #include<iostream>
#include<vector>
#include<limits.h>
#include<queue>
#include<string>
using namespace std;

int main(){
	int n,i,j;
	cin >> n;
	bool A[n][n];
	
	for (i=0;i<n;i++){
		for (j=0;j<n;j++){
			A[i][j]=0;
		}
	}
	
	for (i=0;i<n;i++){
		int id,deg,dam;
		cin >> id >> deg;
		for (j=0;j<deg;j++){
			cin >> dam;
			A[i][dam-1]=1;
		}
	}
	
	for(i=0;i<n;i++){
		for (j=0;j<n-1;j++){
			cout << A[i][j] <<" ";
		}
		cout << A[i][n-1] <<endl;
	}
	
	return 0;
}

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

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

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

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

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

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

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

    return 0;
}

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

using namespace std;

int main(){
  int g[10010][10010]={{0}};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
   {
     cin >> a >> b ;
     for (int i = 0; i < b; ++i)
     {
       cin >> c;
       g[a-1][c-1]=1;/* code */
     }
   }
   for (int i = 0; i < n; ++i)
   {
     for (int j = 0; j < n; ++i)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
   }

}