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;

int main(void)
{
    int n, u, k, v;
    cin >> n;
    vector<vector<int>> vec(n, vector<int>(n));
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            vec[u-1][v-1] = 1;
        }
    }
    
    for (auto& i : vec) {
        int cnt = 0;
        for (auto& j : i) {
            cout << j;
            cnt++;
            if (cnt != n) cout << " ";
        }
        cout << endl;
    }
}

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

int main(){
    int M[N][N];//0 0 起点的邻接矩阵
    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--;//转换为0零起点
        for(int j=0; j<k; j++){
            cin >> v;
            v--;//转换为零起点
            M[u][v] = 1;//在顶点u和顶点v之间画出一条边
        }
    }

    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 <cstdio>
using namespace std;
#define MAX_N (105)
bool G[MAX_N][MAX_N];
int main()
{
    int n;
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	int u, k;
	scanf("%d %d", &u, &k);
	for ( int j = 0; j < k; j++ ) {
	    int v;
	    scanf("%d", &v);
	    G[u-1][v-1] = true;
	}
    }

    for ( int i = 0; i < n; i++ ) {
	for ( int j = 0; j < n; j++ ) {
	    printf("%d%c", (int)G[i][j], (j == n - 1) ? '\n' : ' ');
	}
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int M[101][101];

int main(){
  int n,u,k,v;
  cin>>n;

  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 argc, char** argv)
{
	// Input
	int adj_m[100][100] = { 0 };
	int n;
	cin >> n;
	int u,v,k;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			adj_m[u - 1][v - 1] = 1;
		}
	}

	// Output
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			cout << " " << adj_m[i][j];
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    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++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100]={},v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i] >> k[i];

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<n; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=n)
        cout << " ";
      }

      cout << endl;
    }
  }

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

int main(){
	int n, u, k, v;
	int Graph[100][100] = {};
	
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		cin >> u >> k; //u = ??????????????? k = u?????????????¬???°
		u--;
		for(int j = 0 ; j < k ; j++){
			cin >> v; //v = ??£??\?????????????????????
			v--;
			Graph[u][v] = 1;
		}
	}
	
	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>
using namespace std;

int a[100][100];
int N,u,k,col;
int main() {
	cin >> N;
	for(int i=0; i<N; ++i) {
		cin >> u >> k;
		for(int l=0; l<k; ++l) {
			cin >> col;
			a[u-1][col-1] = 1;
		}
		cout << a[i][0];
		for(int l=1; l<N; ++l) {
			cout << " " << a[i][l];
		}
		cout << endl;
	}
}

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

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

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

int main(){
  int n,u,k,v;
  int G[100][100]={};

  cin >> n;
  for (int i=0;i<n;i++){
    cin >>u>>k;
    for (int j=0;j<k;j++){
      cin >> v;
      G[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for (int j=0;j<n-1;j++){
      cout << G[i][j]<<" ";
    }
    cout << G[i][n-1]<<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;
}