Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	bool M[101][101] = {};
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k; cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v; cin >> v;
			M[u][v] = true;
		}
	}

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

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

#define MAX 100

using namespace std;

int adjacencyList[MAX + 1][MAX + 1];

int main(void)
{

	int n;
	int u;
	int k;
	int v;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> u >> k;

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

	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j > 1) {
				putchar(' ');
			}
			
			printf("%d",adjacencyList[i][j]);
		}

		putchar('\n');

	}


	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int m[101][101];
int main(){
  int n,u,k,v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--; //
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      m[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) printf(" ");
      printf("%d",m[i][j]);
    }
    printf("\n");
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n;
	cin >> n;
	v2 a(n, v1(n, 0));
	rep(i, n){
		int x, y, z;
		cin >> x;
		cin >> y;
		rep(j, y){
			cin >> z;
			a[x-1][z-1]++;
		}
	}
	rep(i, n){
		rep(j, n){
			cout << a[i][j];
			if(j != n-1) cout << " ";
			else cout << endl;
		}
	}
}

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