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 <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int main() {


    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int> > graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(n);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            graph[i][j]=0;
        }
    }

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

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            printf("%d",graph[i][j]);
            if(j!=n-1){
                printf(" ");
            }
        }

    }

    return 0;
}

C++: #include<iostream>
#define SIZE 100

using namespace std;

int main(void) {

	int n, c, v;
	int G[SIZE][SIZE];
	int A[SIZE][SIZE];

	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 >> v;
		cin >> c;
		for (int j = 0; j < c; j++) {
			cin >> G[i][j];
			int tmp = G[i][j];
			if (tmp > 0) {
				A[i][tmp - 1] = 1;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << A[i][j] << " ";
		}
		cout << endl;
	}

	system("pause");

}

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

int main(void){
	int n1, n2, tmp, row;
	cin>>n1;
	vector < vector <int> > M(n1, vector <int>(n1));

	for (int j=0; j<n1; j++){
		cin>>row;
		cin>>n2;
		for (int i=0; i<n2; i++){
			cin>>tmp;
			M[row-1][tmp-1] = 1;
		}
	}

	for (int i=0; i<n1; i++){
		for (int j=0; j<n1; j++){
			if (j == n1-1)
				cout<<M[i][j]<<endl;
			else
				cout<<M[i][j]<<" ";
		}
	}
	return 0;
}

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

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

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++) {
      if(a[i][j] == 1) cout << '1';
	else cout << '0';

      cout << ' ';
    }
    cout <<  endl;
  }
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#pragma warning(disable:4996)
int main(){
	int n = 0;
	int arr[105][105] = { 0 };
	scanf("%d", &n);
	for (int m = 0; m < n; m++){
		int a = 0;
		int b = 0;
		scanf("%d %d", &a, &b);
		for (int x = 0; x < b; x++){
			int c = 0;
			scanf("%d", &c);
			getchar();
			arr[a - 1][c - 1] = 1;
		}
	}
	for (int m = 0; m < n; m++){
		for (int o = 0; o < n-1; o++){
			printf("%d ", arr[m][o]);
		}
		printf("%d", arr[m][n-1]);
		printf("\n");
	}
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <ctime>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int ans[101][101] = {0};
int main() {
	int n;
	cin >> n;
	int a;
	int b;
	int c;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			ans[i][c] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << ans[i][j];
			if (j != n)cout << " ";
			else 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;
}