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 <bits/stdc++.h>
using namespace std;
static void line(int32_t n, vector<int32_t> &v) {
  auto &&it = v.cbegin();
  for (int32_t i = 0; i < n; ++i) {
    cout << (i == 0 ? "" : " ");
    if (!v.empty() && it != v.cend() && i + 1 == *it) {
      cout << 1;
      ++it;
    } else {
      cout << 0;
    }
  }
  cout << endl;
}
int main() {
  int32_t n;
  cin >> n;
  for (int32_t i = 0; i < n; ++i) {
    int32_t skip, k;
    cin >> skip >> k;
    vector<int32_t> v(k);
    for (int32_t j = 0; j < k; ++j) {
      cin >> v[j];
    }
    sort(v.begin(), v.end());
    line(n, v);
  }
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

//??\???????????????
//4
//1 2 2 4
//2 1 4
//3 0
//4 1 3

bool Path[101][101] = {false};

int main(){
    int  N;
    cin >> N;
    int bb;
    for (int i = 1; i <= N; i++) {
        int K;
        scanf("%d %d",&bb,&K);
        for (int k = 0; k < K; k++) {
            int p;
            scanf("%d",&p);
            
            Path[i][p] = true;
        }
    }
    
    for (int r = 1; r <= N; r++) {
        for (int c = 1; c <= N; c++) {
            printf("%d",Path[r][c]);
            if (c != N) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

C++: #include<stdio.h>

int G[101][101];

int main()
{
    int n, i, j, a, b, e;
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
		for(j = 1; j <= n; j++){ G[i][j] = 0; } }

    for(i = 1; i <= n; i++){ scanf("%d %d", &a, &e);
		for(j = 1; j <= e; j++){ scanf("%d", &b); G[a][b] = 1; } }

    for(i = 1; i <= n; i++){ printf("%d", G[i][1]);
	for(j = 2; j <= n; j++){ printf(" %d", G[i][j]); }
        printf("\n");
    }
    return 0;
}

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

int gra[101][101];
int n, a, b, c;

int main(){
 cin>>n;
 for(int i=0; i<n; i++){
  cin>>a>>b;
  for(int j=1; j<=b; j++){
   cin>>c;
   gra[a][c]=1;
  }  
 }
 for(int i=1; i<=n; i++){
  for(int j=1; j<n; j++)
   cout<<gra[i][j]<<" ";
  cout<<gra[i][n]<<"\n";
 }
 return 0;
}

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

using namespace std;

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

	long u,v;
	long  nn;

	vector<vector<int>> g(n + 1, vector<int>(n + 1,0));
	for (int i = 1; i <= n; i++) {

		cin >> u;
		cin >> nn;
		for (int j = 1; j <= nn; j++) {

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

	return 0;

}

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

bool G[101][101];

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

C++: #include<iostream>
using namespace std;
int main()
{
	int degree,number,num,count;
	cin>>degree;
	int arr[100][100];
	for(int i=0;i<degree;i++)
	{
		for(int j=0;j<degree;j++)
		{
			arr[i][j]=0;
		}
	}
	for(int i=0;i<degree;i++)
	{
		cin>>count;
		cin>>number;
		for(int j=0;j<number;j++)
		{
			cin>>num;
			arr[i][num-1]=1;
		}
	}
	for(int i=0;i<degree;i++)
	{
		for(int j=0;j<degree;j++)
		{
			cout<<arr[i][j];
			if(j!=degree-1)
				cout<<" ";
		}
		cout<<endl;
	}
}

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

//??£??\?????????????¬??????????????¨???¶???	array[i][j] i??????j???????????????
//??£??\?????????????????????????????????????????????,?????????????¨???¶
//ALDS1_11-A
int n,u,k,a;
int map[101][101];
int main(){
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			map[i][j]=0;
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u;
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>a;
			map[u][a]=1;
		}
	}
	for(int i=1;i<n+1;i++){
		for(int j=1;j<n+1;j++){
			cout<<map[i][j]<<" ";
			if(j==n&&i!=n)cout<<endl;
		}
	}
	return 0;
}

C++: /*
 * Problem Description: Graph I - Graph
 * Category: Graph
 * Author: Khan
 * Date: 18th October, 2017
 */

#include <iostream>
#include <cstring>
#include <algorithm>

#define MAXN 100

using namespace std;

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int n, G[MAXN + 1][MAXN + 1], t;
    memset(G, 0, sizeof(G));
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> t >> t;
        int tmp;
        for (int j = 0; j < t; ++j)
        {
            cin >> tmp;
            G[i + 1][tmp] = 1;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if(j != 0)
                cout << " ";
            cout << G[i + 1][j + 1];
        }
        cout << endl;
    }
    return 0;
}

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

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

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

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;
}