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>

using namespace std;

static const int N = 100;

int main() {
  int M[N][N];

  int n;
  cin >> n;

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

  int u, k, v;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--; // to 0 origin
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--; // to 0 origin
      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<vector>
using namespace std;

int main()
{
  int n;
  int g[105][105];
  
  cin >> n;

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

    for(int j = 0; j < n; j++) g[u-1][j] = 0;

    for(int j = 0; j < k; j++){
      int v;
      cin >> v;

      g[u-1][v-1] = 1;
      
    }

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

    cout << endl;
    
  }

  return 0;

}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

const int V = 100;
int n;

typedef struct edge_def {
  int from;
  int to;
  int cost;

  edge_def(int _from, int _to, int _cost) {
    from = _from;
    to   = _to;
    cost = _cost;
  }
} edge;

vector<edge> es[V];
int nm[V][V];

int main() {
  int i, j, k;
  memset(nm, 0, sizeof(nm));
  for (i=0; i<V; i++) es[i].clear();
  scanf("%d ", &n);
  for (i=0; i<n; i++) {
    int u, v;
    scanf("%d ", &u);
    scanf("%d ", &k);
    for (j=0; j<k; j++) {
      scanf("%d ", &v); 
      es[u-1].psb(edge(u-1, v-1, 0));
//      es[v-1].psb(edge(v-1, u-1, 0));
//      nm[u-1][v-1] = nm[v-1][u-1] = 1;
      nm[u-1][v-1] = 1;
    }
  }

  for (i=0; i<n; i++)
    for (j=0; j<n; j++)
      printf("%d%c", nm[i][j], ((j==n-1) ? '\n' : ' '));

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n ,i,DP[101][101],num,p,k;
        cin>>n;
    for(i=0;i<n;i++){
    for(int j=0;j<n;j++){
        DP[i+1][j+1]=0;
    }
    }

    for(i=0;i<n;i++){
    cin>>p;
    cin>>num;
    for(int j=0;j<num;j++){
        cin>>k;
        DP[p][k]=1;
    }
    }
for(i=0;i<n;i++){
    for(int j=0;j<n;j++){
        
        if(j==n-1){
         cout<<DP[i+1][j+1]<<endl;  
        }
        else cout<<DP[i+1][j+1]<<" ";
    }
}
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string.h>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

int n;
int adj[105][105];

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  int n,p,q;
  cin>>n;
  int a[100][100]={};
  for (int i=0;i<n;i++){
    cin>>q>>p;
    if (p!=0){
      for (int j=0;j<p;j++){
	a[i][j]=1;
      }
    }
  }
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      cout<<a[i][j];
      if (j!=n-1)cout<<" "; 
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j];
            if(j != n-1)
            cout << " ";
        }
        cout << endl;
    }
}

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

int main(){
  int a[N][N];
  int n,i,j,u,k,v;

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

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1) printf(" ");
      printf("%d",a[i][j]);
    }
    printf("\n");
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int judge(int i,int n,int variable,vector< vector<int> > &v)
{
  for(int j=0;j<v[variable].size();++j){
    if(i==v[variable][j]){
      return 1;
      break;
    }
  }
  return 0;
}
int main()
{
  int n,u,k,vv;
  cin>>n;
  vector< vector<int> > v(n),a(n,vector<int>(n));
  for(int variable=0;variable<n;++variable){
    cin>>u>>k;
    for(int i=0;i<k;++i){
      cin>>vv;
      v[variable].push_back(vv);
    }
  }
  for(int variable=0;variable<n;++variable)
    for(int i=1;i<=n;++i)
      a[variable][i-1]=judge(i,n,variable,v);
  for(int variable=0;variable<n;++variable){
    for(int i=0;i<n;++i){
      cout<<a[variable][i]<<" "<<flush;
    }
    cout<<endl;
  }
}

C++: #include <cstdio>

int main(){
    int i, j, n, u, k, v;
    scanf("%d",&n);
    int A[n][n];
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            A[u-1][v-1] = 1;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            printf("%d",A[i][j]);
            if(j<n-1)printf(" ");
        }
        printf("\n");
    }
    return 0;
}