Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

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

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

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

int main(){
   
    int N;cin>>N;
    vector<vector<int>> S(N,vector<int>(N,0));
    for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        for(int j=0;j<b;j++){
            int k;cin>>k;
            S[i][k-1]=1;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(j) cout<<" ";
            cout<<S[i][j];
        }
        cout<<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                
                if(vec[i][k]==j) {
                    if(j!=n-1){
                        cout << 1 <<" "; 
                        hantei = 1;
                    }else{
                        cout << 1;
                        hantei = 1;
                    }    
                }
            }
            if(hantei==0){ 
                if(j!=n-1){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            }
        }cout << endl;
    }
}

C++: #include <iostream>
#include<stdio.h>

#define MAX 100
using namespace std;

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

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            printf("%d", A[i][j]);
            if(j != n-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int graph[110][110];

int main(){
    int n,u,k,num;
    cin>>n;
    memset(graph,0,sizeof(graph));
    for(int i=1;i<=n;i++){
        cin>>u>>k;
        while(k--){
            cin>>num;
            graph[u][num]=1;
        }
    }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cout<<graph[i][j]<<(j==n?"\n":" ");
}

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

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

  int mat[100][100];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      mat[i][j]=0;

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

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

  return 0;
}

C++: //16D8103013E Sen Shunkou
#include<iostream>
int main(){
    int n;
    std::cin>>n;
    int A[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    int tmp,s,e;
    for(int i=0;i<n;i++){
        std::cin>>s;
        std::cin>>tmp;
        for(int j=0;j<tmp;j++){
            std::cin>>e;
            A[s-1][e-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==0){
                std::cout<<A[i][j];
            }else std::cout<<" "<<A[i][j];
        }
        std::cout<<"\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vvll edges(n, vll(n, 0));
  REP(i, n) {
    ll u, K; cin >> u >> K;
    REP(k, K) {
      ll to; cin >> to;
      edges.at(u-1).at(to-1) = 1;
    }
  }
  REP(i, n){
    REP(j, n) {
      cout << edges.at(i).at(j);
      if (j != n-1) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

const int N_MAX = 100;

// グラフ
// 隣接リスト表現の有効グラフGの隣接行列を出力

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cout << "hello world" << endl;

    int n;
    cin >> n;

    int G[100][100] = { 0 };

    for (int i = 0; i< n; i++)
    {
        int u, k;
        cin >> u; // 頂点番号
        cin >> k; // 出次数
        for (int i = 0; i < k; i++)
        {
            int v;
            cin >> v;
            G[u-1][v-1] = 1;
        }
    }

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