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 <stdio.h>

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

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

    for(int i = 0; i < n; i++){
        int num1;
        scanf("%d", &num1);

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

        int num2;
        for(int j = 0; j < n; j++){
            scanf("%d", &num2);
            V[num1][num2] = 1;
        }
    }

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

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

struct edge{
    int node;
    edge *next;
}nodes[105];

int n,matrix[105][105];

int main()
{
    memset(matrix,0,sizeof(matrix));
    cin>>n;
    int i,j;
    for(i=1;i<=n;i++){
        int ii,n_i;
        cin>>ii>>n_i;
        for(j=0;j<n_i;j++){
            int jj;
            cin>>jj;
            matrix[ii][jj]=1;
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(j!=1)cout<<" ";
            cout<<matrix[i][j];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int graph[100][100] = {0};
	int num;
	int hon;
	int eda;
	int ver;

	cin>>num;
	for(int i=0;i<num;i++){
		cin>>eda;
		cin>>hon;
		for(int j=0;j<hon;j++){
			cin>>ver;
			graph[eda][ver]++;
		}
	}
	for(int i=1;i<=num;i++){
		for(int j=1;j<=num;j++){
			cout<<graph[i][j];
			if(j==num)
				break;
			cout<<" ";
		}
		cout<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN = 100 + 4;
int M[MAXN][MAXN];
int main()
{
    int n, k, u, m;
    memset ( M, 0, sizeof(M) );
    cin>>n;
    for ( int i = 0; i < n; i++ ) {
        cin>>u>>k;
        for ( int j = 0; j < k; j++ ){
            cin>>m;
            M[u][m] = 1;
        }
    }

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

C++: #include <iostream>

using namespace std;

const int N = 100;

int main()
{
    int n, c_num, row, column;
    int adj[N][N] = {};
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> row >> c_num;
        for (int j = 0; j < c_num; j++)
        {
            cin >> column;
            adj[row-1][column-1] = 1;
        }
    }

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

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N]; // 0 オリジンの隣接行列
	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--; // 0 オリジンへ変換
		for ( int j = 0; j < k; j++ ) {
			cin >> v;
			v--; // 0 オリジンへ変換
			M[u][v] = 1; // u と v の間に辺を張る
		}
	}
	
	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>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vector<vector<int>> e(n,vector<int>(n,0));
    rep(i,n){
        int a; cin >> a;
        int tmp; cin >> tmp;

        rep(j,tmp) {
            int to; cin >> to;
            e[i][to-1] = 1;
        }
    }

    cout << e << endl;
}

C++: #include <iostream>

using namespace std;

int main() {

  int n;
  cin >> n;
  int A[110][110];
  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++) {
    int u, k, v;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      A[u-1][v-1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) cout << ' ';
      cout << A[i][j];
    }
    cout << endl;
  }
}

C++: #include<iostream>
#include<queue>
using namespace std;
int main()
{
  int n,u,k,v,**M;
  cin>>n;
  M=new int*[n];
  for(int i=0;i<n;i++)
    {
      M[i]=new int[n];
      for(int j=0;j<n;j++)
	M[i][j]=0;
    }
  int count=0;
  while(count<n)
    {
      count++;
      cin>>u>>k;
      for(int i=0;i<k;i++)
	{
	  cin>>v;
	  M[u-1][v-1]=1;
	}
    }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cout<<' '<<M[i][j];
    cout<<endl;
  }
  delete M;
}