Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: #include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define INFTY 2000000001
#define MAX 101

int n = 0;
int adl[MAX][MAX], deg[MAX];
int adm[MAX][MAX];

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      adm[i][j] = 0;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int num;
    scanf("%d", &num);
    num--;
    scanf("%d", &deg[num]);
    for ( int j = 0; j < deg[num]; j++) {
      scanf("%d", &adl[num][j]);
      adl[num][j]--;
      adm[num][adl[num][j]] = 1;
    }
  }

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

  return 0;
}

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

static const int MAX = 100;

int main(){
    int n;
    scanf("%d",&n);
    int u,k,adj[MAX][MAX],tmp;
    memset(adj,0,sizeof(adj));
    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(int m=0;m<k;m++){
            scanf("%d",&tmp);
            adj[u-1][tmp-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int m=0;m<n;m++){
            if(m) printf(" ");
            printf("%d",adj[i][m]);
            if(m==3) printf("\n");
        }
    }

    return 0;
}

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

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

  vector<vector<int>> g(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      g[i][j] = 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--;
      g[u][a] = 1;
    }
  }

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

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int N_MAX = 101;


int main(void){

	int N; cin >> N;
	int adj[N_MAX][N_MAX];
	REP(i,N) REP(j,N) adj[i][j] = 0;

	REP(i,N){
		int u,k; cin >> u >> k; u--;
		REP(j,k){
			int v; cin >> v; v--;
			adj[u][v] = 1;
		}
	}

	REP(i,N){
		int j;
		for(j=0;j<N-1;++j){
			cout << adj[i][j] << ' ';
		}
		cout << adj[i][j] << endl;
	}


	return 0;

}

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

int main() {

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

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    while(k>0){
      scanf("%d",&l);
      a[u][l] = 1;
      k--;
    }
  }

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

  
  return 0;
}

C++: //16D8103012G 三品海渡
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 2; j < n; j++)
	{
	  if (ln[i][j] != 0 && m[j][i]==0)
	    {
	      m[i][ln[i][j]-1] = 1;
	    }
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
	{
	  cout << m[i][j] << " ";
	}
      cout << endl;
    }
  return 0;
}

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

static const int MAX = 100;

int main(){
    int n;
    scanf("%d",&n);
    int u,k,adj[MAX][MAX],tmp;
    memset(adj,0,sizeof(adj));
    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(int m=0;m<k;m++){
            scanf("%d",&tmp);
            adj[u-1][tmp-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int m=0;m<n;m++){
            if(m) printf(" ");
            printf("%d",adj[i][m]);
            if(m==3) printf("\n");
        }
    }

    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool ans[101][101];
int main(){
  int n,u,k,v;
  cin>>n;
  for(int j=0;j<n;j++){
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v;
      ans[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
      cout<<ans[i][j];
      if(j==n)cout<<endl;
      else cout<<" ";
    }
  return 0;
}

C++: #include <iostream>
using namespace std;
int adj[100][100] = {0};
int main()
{
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		int j, k;
		cin >> j >> k;
		j--;
		for (int m=0;m<k;m++) {
			int a;
			cin >> a;
			a--;
			adj[j][a]=1;
		}
	}

	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			cout << adj[i][j];
			if (j<n) cout << ' ';
		}
		cout << endl;
	}
		
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define NOTUSED 0
using Graph=vector<vector<int>>;

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

    // 隣接リストGを受け取る
    Graph G(n+1);
    G[0]={NOTUSED};
    REP(i,n){
        int u,k;
        cin>>u>>k;
        G[u].resize(k);
        REP(j,k){
            cin>>G[u][j];
        }
    }

    // 隣接行列Aを作成
    Graph A(n+1);
    A[0]={NOTUSED};
    for(int i=1; i<=n; i++){
        A[i].assign(n+1,0);
        A[i][0]=NOTUSED;
        REP(j,G[i].size()){
            A[i][G[i][j]]=1;
        }
    }

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

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>

using namespace std;
int main() {
	int n,m,l,p;
	cin >> n;
	bool 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 >> m;
		cin >> l;
		for(int j = 0; j < l;j++) {
			cin >> p;
			a[m-1][p-1] = 1;
		}
	}
	for ( int i = 0;i < n;i++) {
		for(int j= 0; j < n;j++) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}