Go: package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const N = 100

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var M [N][N]int
	for i := 0; i < n; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		u--
		for j := 0; j < k; j++ {
			sc.Scan()
			v, _ := strconv.Atoi(sc.Text())
			v--
			M[u][v] = 1
		}
	}

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				out.WriteString(" ")
			}
			out.WriteString(fmt.Sprintf("%d", M[i][j]))
		}
		out.WriteString("\n")
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}

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

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

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

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

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

    int M[n][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) {
        int u, k;
        std::cin >> u >> k;
        int v;
        for (int j = 0; j < k; ++j) {
            std::cin >> v;
            M[u-1][v-1] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>
#include <stdio>

using namespace std;

int main(){
  int g[10010][10010]={{0}};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
   {
     cin >> a >> b ;
     for (int i = 0; i < b; ++i)
     {
       cin >> c;
       g[a-1][c-1]=1;/* code */
     }
   }
   for (int i = 0; i < n; ++i)
   {
     for (int j = 0; j < n; ++i)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
   }

}

C++: #include <stdio.h>

int main() {
    int n, m, tmp;
    
    scanf("%d", &n);
    
    int M[n][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++) {
        scanf("%d", &m);
        for (int j=0; j<n; j++) {
            scanf("%d", &tmp);
            M[i][tmp-1] = 1;
        }
    }
    
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(j) printf(" ");
            printf("%d", M[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}

C++: /*
 * ALDS1_11_A.cpp
 *
 *  Created on: May 5, 2018
 *      Author: 13743
 */

#include<iostream>

using namespace std;

int main() {
	int n;
	bool adj[101][101] = {0};
	cin >> n;

	int u, k, v;
	for(int i=0; i<n; i++) {
		cin >> u >> k;
		while(k--) {
			cin >> v;
			adj[u][v] = 1;
		}
	}

	for(int i=1; i<=n; i++) {
		cout << adj[i][1];
		for(int j=2; j<=n; j++) {
			cout << " " << adj[i][j];
		}
		cout << endl;
	}
}

C++: #include <stdio.h>
#define N 100

int main()
{
	int M[N][N];
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			M[i][j] = 0;
		}
	}

	int u, v, k;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &u, &k);
		u--; // 0オリジンへ変換
		
		for (int j = 0; j < k; j++)
		{
			scanf("%d", &v);
			v--; // 0オリジンへ変換
			M[u][v] = 1;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (j > 0)printf(" ");
			printf("%d", M[i][j]);
		}
		printf("\n");
	}
	return 0;
}

C++: #include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int G[101][101];

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

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

		for (int i = 0; i < k; i++)
		{
			int v;
			cin >> v;
			G[id][v] = 1;
		}
	}

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

	return 0;
}

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

#define MAX 101
int graph[MAX][MAX];

int main(){
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			graph[i][j]=0;
		}
	}

	int n,from,k,to;	cin>>n;
	for(int i=0;i<n;i++){
		cin>>from>>k;
		for(int j=0;j<k;j++){
			cin>>to;
			graph[from][to]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j>1)cout<<" ";
			cout<<graph[i][j];
		}
		cout<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>

using namespace std;

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix);

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

    vector<vector<int> > vertex(n, vector<int>(n, -1));
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;

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

    vector<vector<int> > adjacent(n, vector<int>(n, 0));
    to_adjacent_matrix(vertex, adjacent);

    for (int i = 0; i < n; ++i) {
        cout << adjacent[i][0];
        for (int j = 1; j < n; ++j)
            cout << ' ' << adjacent[i][j];
        cout << '\n';
    }
}

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix)
{
    int n = adjacent_list.size();

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n && adjacent_list[i][j] != -1; ++j) {
            int adjacent = adjacent_list[i][j] - 1;
            if (adjacent <= 0 || adjacent > n)
                continue;

            adjacent_matrix[i][adjacent] = 1;
        }
    }
}

C++: #include <iostream>

using namespace std;

const int N = 100 + 1;

int main() {
    int A[N][N] = {{0}};

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

        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            A[u-1][x-1] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;

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

  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] = true;
    }
  }

  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cout << G[i][j]<< ' ';
    }

    cout << endl;
  }

  return 0;
}

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

int main() {
	int n, u, k, x;
	int matrix[101][101] = {};

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> x;
			matrix[u][x] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << matrix[i][j] ;
			if (j != n)	cout << " ";
		}
		cout << endl;
	}
	return 0;
}