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<bits/stdc++.h>
using namespace std;

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> graph(n, vector<int>(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;
            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<bits/stdc++.h>
using namespace std;

int V[100][100] = {{0}};

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

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

int main() {
    int n; cin >> n;
    vector<vector<int>> vec(n, vector<int>(n, 0));

    for (int i = 0; i < n; i++)
    {
        int u, k, tmp; cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> tmp;
            vec.at(i).at(tmp-1)=1;
        }
        
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << vec.at(i).at(j) ;
            if(j!=n-1) cout << " ";
        }
        if(i!=n-1)  cout << endl;
    }
    
}
//g++ -o a.exe a.cpp

C++: #include<iostream>
using namespace std;
int main()
{
	const int MAX = 101;
	int G[MAX][MAX] = {0};
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int u, d;
		cin >> u >> d;
		for (int j = 1; j <= d; j++)
		{
			int v;
			cin >> v;
			G[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (j != n)
				cout << G[i][j] << " ";
			else
				cout << G[i][j] << endl;
}

C++: #include<iostream>
#include<windows.h>
using namespace std;
int graph[105][105];
int main()
{
	int n;
	cin>>n;
	memset(graph,0,sizeof(graph));
	for(int i=1;i<=n;i++)
	{
		int v;
		cin>>v;
		int num;
		cin>>num;
		while(num--)
		{
			int aa;
			cin>>aa;
			graph[v-1][aa-1]=1;
			//cout<<v-1<<" "<<aa<<endl;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j>0)
			cout<<" ";
			cout<<graph[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

int main(void){
    int n;
    cin>>n;
    int* row=(int*)malloc(sizeof(int)*n);
    int u,k;
    int v;
    for(int j=0;j<n;j++){
        for(int i=0;i<n;i++){
            row[i]=0;
        }
        cin>>u>>k;
        for(int i=0;i<k;i++){
            cin>>v;
            row[v-1]=1;
        }
        for(int i=0;i<n-1;i++){
            cout<<row[i]<<" ";
        }
        cout<<row[n-1]<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int M[110][110] = {0}; 
int n; 
cin >> n; 
for (int i = 1; i <= n; ++i){
  int k; 
  cin >> k; 
  int m; 
  cin >> m; 
    for (int l = 1; l <= m; ++l){
     int j; 
     cin >> j;
     M[k][j] = 1; 
    }
  }
for (int i = 1; i <= n; ++i){
  for (int j = 1; j <= n; ++j){
    if(j-1) cout << " "; 
    cout << M[i][j]; 
  }
  cout << endl; 
}
}

C++: #include <cstdio>

using namespace std;

#define MAX 100
int n, AM[MAX][MAX];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int u, k;
        scanf("%d%d", &u, &k);
        for (int j = 1; j <= k; ++j) {
            int vi;
            scanf("%d", &vi);
            AM[i][vi - 1] = 1;
        }
    }

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

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

#define MAX 101
int G[MAX][MAX];
int V;

int main()
{
    std::scanf("%d", &V);
    int source, E, tmp;

    for (int i = 1; i <= V; i++) {
        for (int j = 1; j <=V; j++) G[i][j] = 0;
    }


    for (int i = 0; i < V; i++) {
        std::scanf("%d %d", &source, &E);
        if (E > 0) {
            for (int j = 0; j < E; j++) {
                std::scanf("%d", &tmp);
                G[source][tmp] = 1;
            }
        }
    }

    for (int i = 1; i <= V; i++) {
        for (int j = 1; j <= V; j++) {
            if (j > 1) std::printf(" ");
            std::printf("%d", G[i][j]);
        }
        std::printf("\n");
    }

    return 0;
}

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

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

C++: #include<iostream>
using namespace std;
int a[1050][1050];
int main()
{
    int n;
    cin>>n;
    for(int p=0;p<n;p++)
    {
        int u,k;
        cin>>u>>k;
        while(k--)
        {
            int x;
            cin>>x;
            a[u][x]=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 101

int main() {

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

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    while(k>0){
      scanf("%d",&l);
      a[u][l] = 1;
      k--;
    }
  }

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

  
  return 0;
}