Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

//#include<string>
//#include<cmath>
//#include<map>
//#include<cstdlib>
//#include<deque>
//#include<queue>
//#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j];
      if(j!=N-1) cout << " ";
      else cout << endl;
    }
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}

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

const int N = 100;
int m[N][N];

int main()
{

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int u, k; // k == 出次数
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++)
		{
			int v;
			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 <cstdio>
using namespace std;
int n, G[101][101];
int main() {
  scanf("%d", &n);
  for(int i = 1, u, k; i <= n; ++i) {
    scanf("%d %d", &u, &k);
    for(int j = 1, v; j <= k; ++j) {
      scanf("%d", &v);
      G[u][v] = 1;
    }
  }
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n; ++j) {
      printf("%d", G[i][j]);
      if(j < n) printf(" ");
    }
    printf("\n");
  }
}

C++: #include<iostream>
using namespace std;
static const int 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>
using namespace std;

int main(){

  int n,k,v,u;
  cin>>n;

  double V[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

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


  }

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

  return 0;
}

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

int main(){
        int n,m,l;
        cin >> n;
        int f[100][100] = {};
        for (int i = 0; i < n; i++){
                cin >> m;
                for (int j = 0; j < m; j++){
                        cin >> l ;
                        f[m][l] = 1;
                }
        }
        for (int i = 0; i < n; i++){
                for (int j = 0; j < n-1; j++){
                        cout << f[i][j] << " ";
                }
                cout << f[i][n] << endl;
        }
}

C++: #include <iostream>
//给一个图的邻接表，输出其邻接矩阵

using namespace std;

static const int 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;
    }

}

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

int main()
{
	int n;
	cin >> n;
	int ans[100][100];

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			ans[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		int num2;
		cin >> num2;
		for (int j = 0; j < num2; j++) {
			int num1;
			cin >> num1;
			ans[num - 1][num1 - 1] = 1;
		}
	}

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

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rp(i,j) for(long long i=0;i<j;i++)
#define rep(i,j,k) for(long long i=j;i<k;i++)
#define mod 1000000007
#define NIL -1
typedef long long ll;
vector<int>c[101];
int a[101][101]={0};
int main(){
    int n,u,k,v;cin>>n;
    rp(i,n){
        cin>>u>>k;
        rp(j,k){
            cin>>v;
            c[u].push_back(v);
        }
    }
    rep(i,1,n+1){
        for(auto j:c[i]){
            a[i][j]=1;
        }
    }
    rep(i,1,n+1){
        rep(j,1,n+1){
            if(j!=1)cout<<" ";
            cout<<a[i][j];
        }
        cout<<endl;
    }
}

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

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

C++: #include <iostream>
#include <cstdio> 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
using namespace std;
/*---------------------------------------------------*/

int n,u,k,v;
int g[105][105];

int main(){
  scanf("%d",&n);

  rep(i,n){
    scanf("%d%d",&u,&k);
    rep(i,k){
      scanf("%d",&v);
      g[u][v]=1;
    }
  }
  
  REP(i,1,n+1){
    printf("%d",g[i][1]);
    REP(j,2,n+1){
      printf(" %d",g[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

int main(){

  int n,k,v,u;
  cin>>n;

  double V[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

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


  }

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

  return 0;
}

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

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