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>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

typedef long long ll;
using namespace std;
const int mod = 1000000007;


int main() {

    int n; cin >> n;
    vector< vector<int> > Adj(n, vector<int>(n, 0));

    for (int i = 0; i < n; i++) {
        int u, k; cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v; cin >> v;
            v--;
            Adj[u][v] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j != n-1) {
                cout << Adj[i][j] << ' ';
            }
            else {
                cout << Adj[i][j] << '\n';
            }
        }
    }

}

C++: #include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;

  int** G = new int*[n+1];
  for (int i = 0; i < n; i++) {
    int u,k,v;
    cin >> u >> k;
    G[u] = new int[n+1];
    for (int j = 0; j < k; j++) {
      cin >> v;
      G[u][v] = 1; 
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << G[i][1];
    for (int j = 2; j <= n; j++) {
      cout << " " << G[i][j];
    }
    cout << endl;
  }

  return 0;
}

C++: #include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0||n==1) return dp[n]=1;
  if(dp[n]!=-1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++) dp[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<vector<int>> graph(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            graph[u - 1][v - 1] = 1;
        }
    }

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

}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; vector<vector<int> >vec(n, vector<int>(n, 0));
	rep(i, 0, n) {
		int u, k; cin >> u >> k;
		u--;
		rep(j, 0, k) {
			int v; cin >> v; v--;
			vec[u][v] = 1;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (j)cout << " ";
			cout << vec[i][j];
		}
		cout << endl;
	}
	return 0;
}

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;i<n;j++){
      if(j)cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}

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