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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a[101][101]={};
  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;
      a[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<n;j++)
      cout<<a[i][j]<<' ';
    cout<<a[i][n]<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > graph(n, vector<int>(n, 0));
    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        u--;
        rep(i, k)
        {
            int v;
            cin >> v;
            v--;
            graph[u][v]++;
        }
    }

    rep(i, n)
    {
        rep(j, n)
        {
            if (j == n - 1)
            {
                cout << graph[i][j];
            }
            else
            {
                cout << graph[i][j] << ' ';
            }
        }
        cout << endl;
    }

    return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

// graph
// adjacent list
vector<vector<int>> G; 
// adjacent matrix
const int MAX_N = 100;
int GM[MAX_N][MAX_N];

int main(){
    // input 
    int n; cin >> n;
    G.resize(n);
    rep(i, n){
        int from, edgeNum, to;
        cin >> from >> edgeNum;
        G[from-1].resize(edgeNum);
        rep(j, edgeNum){
            cin >> G[from-1][j];
        }
    }

    // output adjacent matrix
    rep(u, n){
        rep(i, G[u].size()){
            GM[u][G[u][i]-1] = 1; 
        }
    }
    rep(i, n)
        rep(j, n)
            cout << GM[i][j] << (j<n-1? " ": "\n");
}

C++: //
// Created by 李青坪 on 2018/10/31.
//

#include <cstdio>
#include <algorithm>

#define MAXN 101
using namespace std;

int graph[MAXN][MAXN];

void init(){
    for (int i = 0; i < MAXN; ++i) {
        fill(graph[i], graph[i]+MAXN, 0);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    int v, dgr;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v, &dgr);
        int node;
        for (int j = 0; j < dgr; ++j) {
            scanf("%d", &node);
            graph[v][node] = 1;
        }
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            if (i-1) printf(" ");
            printf("%d", graph[k][i]);
        }
        printf("\n");
    }
}
/*
4
1 2 2 4
2 1 4
3 0
4 1 3

 */

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

int n, u, k, uk;
int G[101][101] = {0};

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> u >> k;
		while (k --) {
			cin >> uk;
			G[u][uk] = 1;
		}
	}
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=n; ++j) {
			cout << (j==1 ? "" : " ") << G[i][j];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  std::cin >> n;
  int a[n][n];
  rep(i, n) rep(j, n) a[i][j] = 0;

  rep(i, n) {
    int u, k, v;
    std::cin >> u >> k;
    rep(j, k) {
      std::cin >> v;
      a[u - 1][v - 1] = 1;
    }
  }

  rep(i, n) {
    rep(j, n) {
      if (j) std::cout << ' ';
      std::cout << a[i][j];
    }
    std::cout << '\n';
  }
  return 0;
}

C++: #include <cstdint>
#include <vector>

using namespace std;
#define GRAPH_SIZE 100

static vector<uint32_t> graph[GRAPH_SIZE];

void graph_to_matrix(vector<uint32_t> graph[], uint32_t matrix[][GRAPH_SIZE])
{
  for(uint32_t i = 0; i < GRAPH_SIZE; i++){
    for(uint32_t j = 0; j < GRAPH_SIZE; j++){
      matrix[i][j] = 0;
    }
  }

  for(uint32_t i = 0; i < GRAPH_SIZE; i ++){
    for(uint32_t j = 0; j < graph[i].size(); j++){
      uint32_t val = graph[i][j];
      matrix[i][val] = 1;
    }
  }
}

#include <iostream>

static uint32_t matrix[GRAPH_SIZE][GRAPH_SIZE];

int32_t main(void)
{
  uint32_t num;
  cin >> num;
  for(uint32_t i = 0; i < num; i++){
    uint32_t index, len;
    cin >> index >> len;
    for(uint32_t j = 0; j < len; j++){
      uint32_t val;
      cin >> val;
      graph[index - 1].push_back(val - 1);
    }
  }
  graph_to_matrix(graph, matrix);

  for(uint32_t i = 0; i < num; i++){
    for(uint32_t j = 0; j < num; j++){
      if(j != 0) cout << " ";
      cout << matrix[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

int main(void){
  int m, a[100][100];
  int b[100][100];

  cin >> m;

  for(int i=0; i<m; i++){
    cin >> a[i][0];
    cin >> a[i][1];

    for(int j=2; j<a[i][1]+2; j++){
      cin >> a[i][j];
      b[i][ a[i][j]-1 ] = 1;
    }
  }

  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){
      cout << b[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#define b 100
int main(){
    int n,hang,lie,cisu;
    scanf("%d",&n);
    int mtx[b][b]={0};
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&hang,&cisu);
        for(int j=0;j<cisu;j++){
            scanf("%d",&lie);
            mtx[hang-1][lie-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for (int j=0; j<n-1; j++) {
            printf("%d ",mtx[i][j]);
            }
        printf("%d",mtx[i][n-1]);
        printf("\n");
    }
}