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>
using namespace std;

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

C++: #include <iostream>

int main(){
	int n,k,u,v;
	bool G[100][100] = {};
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u>>k;
		for(int j=0;j<k;j++){
			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;
}

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

int A[101][101];

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

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

int main(void) {
    int  n;
    cin>>n;
    int g[101][101];
    for(int i=1;i<=n;i++) {
        int u,k;
        cin>>u>>k;
        for(int j=1;j<=k;j++) {
            int v;cin>>v;
            g[u][v]=1;
        }
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            if(j!=1) cout<<" ";
            cout<<g[i][j];
        }
        cout<<"\n";
    }
    return 0;
}

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)
#define REP(i, first, to) for(ll i = first; i <= to; ++i)

using namespace std;
typedef long long ll;

list<int> from[101];
int to[101][101];
int n;
void solve() {
	cin >> n;
	rep(i, 0, n) {
		int u, k;
		cin >> u >> k;
		rep(j, 0, k) {
			int value;
			cin >> value;
			from[u].push_back(value);
		}
	}
	REP(i, 1, n) {
		while(!from[i].empty()) {
			to[i][from[i].front()] = 1;
			from[i].pop_front();
		}
	}
	REP(i, 1, n) {
		REP(j, 1, n) {
			if (j == n) {
				cout << to[i][j] << endl;
			} else {
				cout << to[i][j] << " ";
			}
		}
	}
}

int main() {
	solve();
	return 0;
}

C++: #include<iostream>

using namespace std;

static const int N = 100;

int main() {
  int M[N][N]

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }

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

  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 <iostream>
#define MAX 101

using namespace std;


int main()
{
	int matrix[MAX][MAX] = {0};
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		int u, k, v;
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> v;
			matrix[u][v] = 1;			
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if(j) cout << ' ';
			cout << matrix[i+1][j+1];		
		}
		cout << endl;
	}
}

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

int main(){
    int n;

    cin >> n;
    vector<vector<int>> a(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;
            a[u - 1][v - 1] = 1; 
        }
        
    }

    for(auto vv: a){
        for(int i = 0; i < n; i++){
            cout << vv[i];
            if(i != n - 1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

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

#define N 100

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

  int G[N + 1][N + 1];
  for ( int i = 0; i <= n; i++ ) {
    for ( int j = 0; j <= n; j++ ) {
      G[i][j] = 0;
    }
  }

  for ( int i = 1; i <= n; i++ ) {
    int a, b;
    cin >> a >> b;
    for ( int j = 1; j <= b; j++ ) {
      int c;
      cin >> c;
      G[a][c] = 1;
    }
  }

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

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
using Matrix = vector<vector<int>>;
Matrix d;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    d = Matrix(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;
            d[u][v-1] = 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(j!=n-1)cout << d[i][j] << " ";
            else cout << d[i][j] << endl;
        }

    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

void printarray(int n, int a[])
{
    for (int i = 1; i < n + 1; i++)
    {
        cout << a[i];
        if (i != n)
            cout << " ";
    }
    cout << endl;
}

int cycleanalysis(int n, int a[])
{
    int pos, ret, next;
    pos = 0, ret = 0;
    for (int i = 1; i < n + 1; i++)
    {
        pos = i;
        while (a[pos] != pos)
        {
            ret += (a[pos] + a[a[pos]]);
            next = a[pos];
            swap(a[pos], a[a[pos]]);
            pos = next;
        }
    }

    return ret;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, v, m, x;
    cin >> n;
    int a[n][n] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> v >> m;
        for (int j = 0; j < m; j++)
        {
            cin >> x;
            a[v-1][x - 1] = 1;
        }
        for (int k = 0; k < n; k++){
            cout << a[i][k];
            if (k != n-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)