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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A

bool map[100][100];
int main() {
	int n;
	cin >> n;
	//bool map[n][n] = {0};
	for (int i = 0; i < n; i++) {
		int a, c;
		cin >> a >> c;
		for (int j = 0; j < c; j++) {
			int b;
			cin >> b;
			map[a - 1][b - 1] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << (map[i][0] ? "1" : "0");
		for (int j = 1; j < n; j++) {
			cout << " " << (map[i][j] ? "1" : "0");
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#define rep(i,n)for(int i=1;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector< vector<int> >g(n + 1, vector<int>(n + 1, 0));
    rep(i, n + 1)
    {
        int u, k;
        cin >> u >> k;
        rep(j,k+1)
        {
            int v;
            cin >> v;
            g[u][v] = 1;
        }
    }
    rep(i, n + 1)
    {
        rep(j, n + 1)
        {
            cout << g[i][j];
            if(j!=n)cout<<" ";
        }
        cout << endl;
    }
    return 0;
}

C++: // グラフの表現
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
using namespace std;

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; //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<stdio.h>
#define N 100

main(){
int M[N][N];
int n,u,k,v;
int i,j;

scanf("%d",&n);

for(i=0;i<n;i++){
for(j=0;j<n;j++)M[i][j]=0;
}

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

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

return 0;
}

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

int main(){
    int i,j,n,k,u,v,M[N+1][N+1];

    scanf("%d",&n);

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            M[i][j]=0;
        }
    }

    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            M[u-1][v-1]=1;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(j!=0) printf(" ");
            printf("%d",M[i][j]);
        }
        puts("");
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define INFTY (1<<30)
#define MAX 100000000

using namespace std;

int main() {
	int n, m[101][101] = {};
	cin >> n;
	for( int i = 1; i <= n; i++) {
		int u, k;
		cin >> u >> k;
		for( int j = 1; j <= k; j++) {
			int v;
			cin >> v;
			m[i][v] = 1;
		}
	}
	for( int i = 1; i <= n; i++) {
		for( int j = 1; j <= n; j++) {
			if( j < n) cout << m[i][j] << ' ';
			else cout << m[i][j];
		}
		cout << endl;
	}

    return 0;
}

C++: #include <stdio.h>

int main(){
  int n,u,adj[110][110],k,v[100],i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v[j]);
      adj[u-1][v[j]-1]=1;
    }
  }

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


  return 0;

}

C++: //Aizu11A 16D8104015E Nobushige Sen 18.6.22

#include<iostream>
using namespace std;
 
int x[15000][15000],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;
}