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++: //
// Created by 李青坪 on 2018/10/31.
//

#include <cstdio>
#include <algorithm>

#define MAXN 101
using namespace std;

int graph[MAXN][MAXN];

void init(){
    for (auto &i : graph) {
        fill(i, i +MAXN, 0);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    init();
    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 <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
static const int N = 100;

int main() {
	int a[N][N];
	int n, u, k, v;
	cin >> n;

	rep(i, n) rep(j, n) a[i][j] = 0;

	rep(i, n) {
		cin >> u >> k;
		u--;
		rep(j, k) {
			cin >> v;
			v--;
			a[u][v]++;
		}
	}


	rep(i, n){
		rep(j, n) {
			if (j) cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <sstream>

using namespace std;

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

  int A[n + 1][n + 1];
  for (auto row : A) {
    fill(row, row + n + 1, 0);
  }

  for (string line; getline(cin, line);) {
    istringstream is{line};
    int i, j;
    is >> i;
    int k;
    is >> k; // # of neighbors; don't use
    while (is >> j)
      A[i][j] = 1;
  }

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

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
vector<int> adj[100];
int res[100][100] = {0};

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

C++: #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int e[105][105];
int main()
{
    int n;
    int k,m,p;
    memset(e,0,sizeof(e));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&k);
        scanf("%d",&m);
        for(int j=1;j<=m;j++)
        {
            scanf("%d",&p);
            e[k][p] = 1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j != n)
                printf("%d ",e[i][j]);
            else
                printf("%d",e[i][j]);
        }

        printf("\n");
    }
    return 0;

}

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

int n;
int M[101][101];
int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int v, k;
        cin >> v >> k;
        for (int j = 0; j < k; ++j) {
            int s;
            cin >> s;
            M[v][s] = 1;
        }
    }

    for (int l = 1; l <= n; ++l) {
        for (int i = 1; i <= n; ++i) {
            cout << M[l][i];
            if (l != n && i != n) cout << " ";
        }
        if (l != n)
        cout << endl;
    }

    return 0;
}

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

#define 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>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int mat[101][101];

int main(int argc,char* argv[]){
  memset(mat,0,sizeof(mat));
  int n,v,cnt,x;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>v>>cnt;
    for(int j=0;j<cnt;j++){
      cin>>x;
      mat[v][x]=1;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout<<mat[i][j];

      if(j!=n)
	cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int>> Adj(n,vector<int>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u,j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);

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