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 <array>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)



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

    int mat[100][100];
    REP(i, n) {
        REP(j, n) {
            mat[i][j] = 0;
        }
    }

    REP(_, n) {
        int u, k;
        cin >> u >> k;

        REP(_, k) {
            int v;
            cin >> v;
            mat[u-1][v-1] = 1;
        }
    }

    REP(i, n) {
        REP(j, n) {
            cout << mat[i][j];
            cout << (j == n-1 ? '\n' : ' ');
        }
    }

    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++){
      if(j == n) {
	printf("%d",a[i][j]);
      }else{
	printf("%d ",a[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;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>

using namespace std;


int main() {
	int n;
	int u, v;
	int Adj[101][101];
	int deg;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			Adj[i][j] = 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		cin >> u;
		cin >> deg;
		for (int j = 1; j <= deg; j++) {
			cin >> v;
			Adj[u][v] = 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			printf(" %d", Adj[i][j]);
		}
		printf("\n");
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int g[n + 1][n + 1];
    //?????????
    for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= n; j++) {
	    g[i][j] = 0;
	}
    }
    //input
    for (int i = 1; i <= n; i++) {
	int a;
	cin >> a;
	int b;
	cin >> b;
	for (int j = 1; j <= b; j++) {
	    int c;
	    cin >> c;
	    g[a][c] = 1;
	}
    }
    for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= n; j++) {
	    cout << g[i][j] << " ";
	}
	cout << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int a[101][101];
void init(int n){
	for (int i = 1;i <= n;i++){
		for (int j = 1;j <= n;j++){
			a[i][j] = 0;
		}
	}
}
int main()
{
	int n;
	while (cin >> n){
		init(n);
		int x,m,y;
		for (int i = 1;i <= n;i++){
			cin >> x >> m;
			while (m--){
				cin >> y;
				a[x][y] = 1;
			}
		}
		for (int i = 1;i <= n;i++){
			for (int j = 1;j <= n;j++){
				cout << a[i][j] << " ";
			}
			cout << endl;
		}
	}
	return 0;
}

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

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

    vector<vector<int>> adj(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++)
    {
        int a, k;
        cin >> a >> k;
        for (int j = 0; j < k; j++)
        {
            int x;
            cin >> x;
            adj[a - 1][x - 1] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;

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

}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int n, adj[101][101];

int main()
{
  scanf("%d", &n);
  int u, k, v;
  for(int i=0; i<=n; i++)
  {
    for(int j=0; j<=n; j++)
    {
      adj[i][j] = 0;
    }
  }
  for(int i=0; i<n; i++)
  {
    scanf("%d%d", &u, &k);
    for(int j=0; j<k; j++)
    {
      scanf("%d", &v);
      adj[u][v] = 1;
    }
  }
  for(int i=1; i<=n; i++)
  {
    for(int j=1; j<=n; j++)
    {
      if(j!=1) printf(" ");
      printf("%d", adj[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;
}