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 REP(i, n) for(int i = 0;i < n;i++)
#define REP(j, n) for(int j = 0;j < n;j++)
using namespace std;

int main()
{
	int i,n,u;
	int v[100][100];
	cin >> n;
	REP(i,n){
		cin >> u;
		cin >> k;
		REP(i,k){
			cin >>v[i][k];
		}
	}
	REP(i,n){
		REP(j,n){
			cout << v[i][j] << " ";
		}
		cout<<endl;
	}
}

C++: #include <iostream>

#define MAX 100

using namespace std;

int adjacencyList[MAX + 1][MAX + 1];

int main(void)
{

	int n;
	int u;
	int k;
	int v;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> u >> k;

		for (int j = 0; j < k; j++) {
			cin >> v;
			adjacencyList[u][v] = 1;
		}

	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j > 1) {
				putchar(' ');
			}
			
			printf("%d",adjacencyList[i][j]);
		}

		putchar('\n');

	}


	return 0;
}

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

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

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

using namespace std;

#define rep(a, b) for(int i = a; i <= b; i++)

const int MAX = 1e2 + 10;
bool s[MAX][MAX];

int main()
{
	int n;
	while(~scanf("%d", &n))
	{
		rep(1, n)
		{
			int row;
			scanf("%d", &row);
			int num;
			scanf("%d", &num);
			for(int j = 1; j <= num; j++)
			{
				int column;
				scanf("%d", &column);
				s[row][column] = true;
			}
		}
		rep(1, n)
		{
			for(int j = 1; j <= n; j++)
			{
				printf("%d", s[i][j]);
				if(j != n)
					printf(" ");
				else
					printf("\n");
			}
		}
	}
	return 0;
}

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

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

C++: /* 
 * ALDS1_11.cpp
 * ??£??\???????????¨?????§???????????????????????°??????G?????£??\????????¨?????????????????????????????????
 */
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

using Adjacents = vector<int>;
using Vertexes = vector<Adjacents>;

int main(void) {

    int N;
    scanf("%d", &N);

    Vertexes vs;
    vs.resize(N);
    for (int i = 0, id, num; i < N; ++i) {
        scanf("%d %d", &id, &num);
        for (int j = 0, vert; j < num; ++j) {
            scanf("%d", &vert);
            vs[id-1].push_back(vert);
        }
    }

    int **matrix = new int*[N];
    for (int i = 0; i < N; ++i) {
        matrix[i] = new int[N];
        memset(matrix[i], 0, sizeof(int)*N);
        for (int j = 0; j < vs[i].size(); ++j) {
            matrix[i][vs[i][j] - 1] = 1;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            //printf("%2d", matrix[i][j]);
            putchar(matrix[i][j]);
            if (j != N - 1)
                putchar('\n');
        }
        delete[] matrix[i];
        printf("\n");
    }
    delete[] matrix;

    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>

int main()
{
	const int Max = 100;
	int matrix[Max][Max] = { 0 };
	int n, m, l;
	int temp;
	
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> m >> l;
		for (int j = 0; j < l; j++) {
			std::cin >> temp;
			matrix[m - 1][temp - 1] = 1;
		}
	}

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

	return 0;
}

C++: #include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <deque>
#include <vector>
#define MAX 10010
#define rep(i,p) for(int i=0;i<p;i++)
#define pb push_back
using namespace std;
int n,hoge,foo;
int graph[MAX][MAX] = {0};
int main(){
  cin >> n;
  rep(i,n) {
    cin >> hoge >> foo;
    rep(j,foo) {
      cin >> hoge;
      graph[i][hoge-1] = 1;
    }
  }
  rep(i,n) {
    rep(j,n) cout << graph[i][j] << " ";
    cout << endl;
  }
  return 0;
}

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


int main(){
    int n;
    cin>>n;
    
    vector<vector<int>> a(n,vector<int> (n,0));
    
    vector<vector<int>> v(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 m;
            cin>>m;
            a.at(u-1).at(m-1)=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            cout<<a.at(i).at(j)<<" ";
        }
        cout<<a.at(i).at(n-1)<<endl;
    }
}

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

int a[101][101] = {}; //???????????????u??¨u?????£??\?????????????????????v  u??????v???????????£???????????°1

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

  int u,k,v;
  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];

      cout << " ";
    }
    cout <<  endl;
  }
  return 0;
}