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;

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;
}