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 N 101
using namespace std;
int A[N][N];
int n;
int main(){
    int k,num;
    int e;
    cin>>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>>k;
        k--;
        cin>>num;
        for(int j=0;j<num;j++){
            cin>>e;
            e--;
            A[k][e]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j) cout<<' ';
            cout<<A[i][j];
        }
        cout<<endl;
    }
}

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

int main() {
	int n,graph[100][100];
	cin >> n;

	for (int i = 0; i < n; i++) {
		int vertex,jisu;
		cin >> vertex>>jisu;
		vertex--;
		for (int j = 0; j < jisu; j++) {
			int to;
			cin >> to;
			to--;
			graph[vertex][to] = 1;
		}
	}

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

	return 0;
}

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

int main(void){
    int n,u,k,i,j,x;
    bool path[110][110];
    memset(path,0,sizeof(path));
    cin>>n;
    for(i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(j=0;j<k;j++){
            cin>>x;
            x--;
            path[u][x]=true;
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<n-1;j++){
            cout<<path[i][j]<<" ";
        }
        cout<<path[i][n-1]<<endl;
    }
    
    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n, u, k, v, adj[110][110]={0};
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>u>>k;
        for (int j=0; j<k; j++)
        {
            cin>>v;
            adj[u][v]=1;
        }
    }
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (j!=n) cout<<adj[i][j]<<' ';
            else cout<<adj[i][j]<<'\n';
        }
    }
    return 0;
}

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

void fnInput(vector<vector<int>> &rvvnAdjcy)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvvnAdjcy.resize(nMaxSiz + 1, vector<int>(nMaxSiz + 1, 0));
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nx, nSecSiz;
    cin >> nx >> nSecSiz;
    for (int j = 0; j < nSecSiz; j++)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
}

void fnResult(const vector<vector<int>> &cnrvvnAdjcy)
{
  for (int i = 1; i < cnrvvnAdjcy.size(); i++)
  {
    for (int j = 1; j < cnrvvnAdjcy[i].size(); j++)
    {
      if (j != 1) cout << " ";
      cout << cnrvvnAdjcy[i][j];
    }
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;

  fnInput(vvnAdjcy);
  fnResult(vvnAdjcy);

  return 0;
}

C++: #include <stdio.h>
int main(){
  int n,k,V[100][100],adj[100][99],i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)V[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&adj[i][0],&k);
    for(j=1;j<=k;j++){
      scanf("%d",&adj[i][j]);
      V[i][adj[i][j]-1]=1;
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",V[i][j]);
      if(j!=n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1 << 21;
const ll MOD = 1e9 + 7;

int graph[100][100];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    memset(graph, 0, sizeof(graph));
    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, k)
        {
            int v;
            cin >> v;
            v--;
            graph[u][v] = 1;
        }
    }
    rep(i, n)
    {
        rep(j, n)
        {
            cout << graph[i][j];
            if (j != n-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main(void){

    int n, k;

    cin >> n;
    vector<vector<bool> > A(n, vector<bool>(n, false));
    for(int i = 0; i < n; i++){
        cin >> k >> k;
        for(int j = 0; j < k; j++){
            int input;
            cin >> input;
            A[i][input-1] = true;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;

int n,u,k,v;
int a[101][101]={};

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

C++: #include <cstdio>
#define REP0(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,a,b,x;
  int V[100][100]={0};
  scanf("%d",&n);
  REP0(i,n){
    scanf("%d %d",&a,&b);
    REP0(j,b){
      scanf("%d",&x);
      V[a-1][x-1]=1;
    }
  }
  REP0(i,n){
    REP0(j,n){
      if(j) printf(" ");
      printf("%d",V[i][j]);
    }
    printf("\n");
  }
  return 0;
}