Go: package main

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

func main() {
	var n int
	fmt.Scanf("%d", &n)

	adj := make([][]string, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]string, n)
		for j := 0; j < n; j++ {
			adj[i][j] = "0"
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		sc.Scan()
		adjList := strings.Split(sc.Text(), " ")
		outDegree, _ := strconv.Atoi(adjList[1])

		if outDegree > 0 {
			for k := 0; k < outDegree; k++ {
				j, _ := strconv.Atoi(adjList[k+2])
				adj[i][j-1] = "1"
			}
		}
	}

	for i := 0; i < len(adj); i++ {
		fmt.Println(strings.Join(adj[i], " "))
	}

}

C++: #include <iostream>

#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int n;
typedef vector<vector<int> > AdjMatrix;
AdjMatrix graph;


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


    REP(i, n){
        REP(j, n){
            cout << graph[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
        int n, m, k, r;
        cin>>n;
        int a[n][n];
        for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                        a[i][j] = 0;
        for(int i=0;i<n;i++){
                cin>>r;
                cin>>m;
                for(int j=0;j<m;j++){
                        cin>>k;
                        a[r-1][k-1] = 1;
                }
        }
        for(int i=0;i<n;i++){
                for(int j=0;j<n;j++)
                        cout<<a[i][j]<<" ";
                cout<<endl;
        }
        return 0;
}

C++: #include<iostream>
#include<queue>
using namespace std;
void bfs(int src)
{
  queue<int>Q;
  Q.
}

int main()
{
  int n,u,k,v,**M;
  cin>>n;
  M=new int*[n];
  for(int i=0;i<n;i++)
    {
      M[i]=new int[n];
      for(int j=0;j<n;j++)
	M[i][j]=0;
    }
  int count=0;
  while(count<n)
    {
      count++;
      cin>>u>>k;
      for(int i=0;i<k;i++)
	{
	  cin>>v;
	  M[u-1][v-1]=1;
	}
    }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cout<<' '<<M[i][j];
    cout<<endl;
  }
  delete M;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> edges(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--;
            edges[u][v] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0) {
                cout << " ";
            }
            cout << edges[i][j];
        }
        cout << endl;
    }
}

C++: #include<iostream>
using namespace std;
int M[100][100];

int main()
{
    int n;
    int r,node,c;

    cin >> n;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            M[i][j]=0;
            //cout << "hhh" << endl;
        }
    }

    for(int i=0;i<n;i++)
    {
        cin >> r;
        if(i==r-1)
        {
            //cout << "hhh" << endl;
            cin >> node;
            for(int j=0;j<node;j++)
            {
                cin >> c;
                M[r-1][c-1]=1;
            }
        }

    }

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


    return 0;
}

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


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

C++: // 
// 問題URL: 
// 中央*右
// 

#include <iostream>

using namespace std;

int N, u, k, v, Adj[105][105]={};

int main(){
    cin >> N;

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

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            cout << Adj[i][j];
            if(j==N) cout << endl;
            else cout << " ";
        }
    }
}

C++: #include <stdio.h>
int main(){
    int n,a,m,temp,graph[101][101];
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            graph[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&m);
        for(int j=0;j<m;j++){
            scanf("%d",&temp);
            graph[a][temp]++;
        }
    }
    for(int i=1;i<=n;i++){
        printf("%d",graph[i][1]);
        for(int j=2;j<=n;j++){
            printf(" %d",graph[i][j]);
        }
        printf("\n");
    }
}

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

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

    return 0;
}

C++: // ALDS1_11_A.cpp
// Graph I - Graph

#include <iostream>
#include <vector>
using namespace std;

void print(vector<vector<int>> &A, int n)
{
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
}

int main()
{
    int n;
    cin >> n;
    int id;
    int num;
    vector<vector<int>> A(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> id >> num;
        if (num == 0) continue;
        else {
            int tmp;
            for (int j = 0; j < num; j++) {
                cin >> tmp;
                A[id - 1][tmp - 1] = 1;
            }
        }
    }

    print(A, n);

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;


int main(void){
  int n,a,b,c;
  cin >> n;
  int v[n][n];
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<b;j++){
      cin >> c;
      v[a-1][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i][j]!=1)cout << 0 << ' ';
      else cout << v[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

#define N 100

int main()
{
	int m[N][N] = {0};
	
	int n;	cin >> n;

	int v, in, out;
	for (int i = 0; i < n; ++i)
	{
		cin >> in >> v;
		for (int j = 0; j < v; ++j)
		{
			cin >> out;
			m[in - 1][out - 1] = 1;
		}
	}

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

	return 0;
}