Go: package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int n;
    cin >> n;
    int ans[n][n];
    rep (i, n) rep (j, n) ans[i][j] = 0;
    rep (i, n) {
        int a, k;
        cin >> a >> k;
        rep (j, k) {
            int b;
            cin >> b;
            ans[a - 1][b - 1] = 1;
        }
    }
    rep (i, n) {
        rep (j, n) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << "\n";
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  const int INF = 1e7;  //とても大きい値を無限としておく。
int u,k;
cin >> u>> k;  //Vは与えられた頂点数,Eは辺の数
vector<vector<int>> a(u,vector<int>(u,INF));//V*Vを無限で初期化
for(int i=0;i<k;++i){
    //s→tへの有向辺として入力が与えられたとする。//wは重み
    int s,t;       //,w
    cin >> s >> t; //>>w
    a[s][t] = 1;   //a[s][t] = w;
    //a[t][s] = 1; (s-tの無向辺の場合)
}
  
    
}

C++: #include<iostream>
using namespace std;
int N,n,u,k,v;
int main()
{
    cin>>N;
    int A[N][N];
    for(int p=0;p<N;p++)
        for(int q=0;q<N;q++)
            A[p][q]=0;
    for(n=0;n<N;n++)
    {
        cin>>u>>k;
        for(int i=0;i<k;i++)
        {
            cin>>v;
            A[u-1][v-1]=1;
        }
    }
    for(int p=0;p<N;p++)
    {
        for(int q=0;q<N-1;q++)
        {
            cout<<A[p][q]<<' ';
        }
        cout<<A[p][N-1]<<endl;
    }
    return 0;
}

C++: #include <cstdio>

#define N 100
int main(){
    int a[N+1][N+1] = {};

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

    for(int i = 1; i <= n; ++i){
        int id;
        std::scanf("%d", &id);
        int m;
        std::scanf("%d", &m);
        for(int j = 1; j <= m; ++j){
            int x;
            std::scanf("%d", &x);
            a[id][x] = 1;
        }
    }
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            std::printf("%d", a[i][j]);
            if(j != n) std::printf(" ");
            else std::printf("\n");
        }
    }

    return 0;
}

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