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<iostream>
using namespace std;

int x[30000][30000],n,q,r,b;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> q >> r;
		for (int j = 0; j < r; j++) {
			cin >> b;
			x[i][b] == true;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) { cout << ' '; }
			cout << x[i][j+1];
		}
		cout << endl;
	}
	return 0;
}

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

int n;
int ad_list[101][101];

void print(){
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            cout << ad_list[i][j];
            if(j==n)cout << "\n";
            else cout << " ";
        }
    }
}

int main(){
    cin  >> n;
    for(int i=1;i<n+1; i++){
        for(int j=1; j<n+1; j++){
            ad_list[i][j]=0;
        }
    }
    int v,k, in;
    for(int i=1; i<n+1; i++){
        cin >> v >> k;
        for (int j=0;j<k;j++){
            cin >> in;
            ad_list[v][in]=1;
        }
    }
    print();
}

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<bits/stdc++.h>
using namespace std;
const int MAXN = 100+7;
struct node{
    int id;
    struct node* next;
};
struct node* graph[MAXN];
int matrix[MAXN][MAXN];
int main() {
    int n;
    scanf("%d", &n);
    int i;
    for(i = 1; i <= n; i++){
        graph[i] = (node*)malloc(sizeof(node));
        graph[i]->next = NULL;
    }
    memset(matrix, 0, sizeof(matrix));
    for(i = 0; i < n; i++){
        int pnum;
        int k;
        scanf("%d", &pnum);
        scanf("%d", &k);

        int j;
        for(j = 0; j < k; j++){
            int r;
            scanf("%d", &r);
            node* newp = (node*)malloc(sizeof(node));
            newp->id = r;
            newp->next = NULL;
            node* p = graph[pnum];
            while(p->next!=NULL){
                p = p ->next;
            }
            p->next = newp;
        }
    }
    for(i = 1; i <= n; i++){
        struct node* p = graph[i]->next;
        while(p!=NULL){
            matrix[i][p->id] = 1;
            p = p->next;
        }
    }
    for(i = 1; i <= n; i++){
        int j;
        for(j = 1; j <= n; j++){
            if(j!=1) printf(" ");
            printf("%d", matrix[i][j]);
        }
        printf("\n");
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {

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

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

  return 0;
}

// EOF

C++: #include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;;
using vvi=vector<vi>;
using vb=vector<bool>;
using pii=pair<int,int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vector<vb> matr(n,vb(n,false));
    rep(i,0,n){
        int index;
        cin>>index;
        index--;
        int num,in;
        cin>>num;
        rep(c,0,num){
            cin>>in;
            in--;
            matr[index][in]=true;
        }
    }
    rep(i,0,n){
        int cnt=0;
        rep(j,0,n){
            if(cnt++)cout<<" ";
            cout<<matr[i][j];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>

int main() {
    int node_num(0);
    std::cin >> node_num;

    /* Generate Empty Matrix */
    int** graph(nullptr);
    graph = new int*[node_num];
    for (int i(0); i < node_num; ++i) {
        graph[i] = new int[node_num];
        for(int j(0); j < node_num; ++j) {
            graph[i][j] = 0;
        }
    }

    /* Input and Modify Matrix*/
    for(int i(0); i < node_num; ++i) {
        int node_index(0);
        int node_degree(0);
        std::cin >> node_index >> node_degree;
        for(int j(0); j < node_degree; ++j) {
            int tmp(0);
            std::cin >> tmp;
            graph[node_index-1][tmp-1] = 1;
        }
    }

    /* Output 隣接行列 */
    for(int i(0); i < node_num; ++i) {
        for(int j(0); j < node_num; ++j) {
            if(j != 0) {
                std::cout << " ";
            }
            std::cout << graph[i][j];
        }
        std::cout << "\n";
    }

    for(int i(0); i < node_num; ++i ){
        delete graph[i];
    }

    delete graph;

    return 0;
}

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

int main(){
    int n;cin >> n;
    vector<vector<int>> vec(n,vector<int>(n));
    for(int i=0;i<n;i++){
        int j,k;cin >> j >> k;
        j--;
        for(int t = 0;t<k;t++){
            int s;cin >> s;s--;
            vec[j][s] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << vec[i][j];
            if(j!=n-1) cout << " ";
            else cout << endl;
        }
    }
}

C++: #include <iostream>
#include <stdio>

using namespace std;

int main(){
  int g[10010][10010]={};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
   {
     cin >> a >> b ;
     for (int i = 0; i < b; ++i)
     {
       cin >> c;
       g[a-1][c-1]=1;/* code */
     }
   }
   for (int i = 0; i < n; ++i)
   {
     for (int j = 0; j < n; ++i)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
   }

}