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

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

C++: #include <cstdio>

int main() {
    int n;
    scanf("%d", &n);

    int M[n][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++) {
        int u, degree;
        scanf("%d %d", &u, &degree);
        u--;    // convert to 0 index
        for (int j = 0; j < degree; j++) {
            int v;
            scanf("%d", &v);
            v--;    // convert to 0 index
            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");
    }
}

C++: #include <iostream>
#include <cassert>
#include <string.h>
#include <vector>
#include <map>

using namespace std;

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

    vector<vector<int>> matrix;
    for (int i = 0; i < n; ++i)
    {
        vector<int> line;
        for (int j = 0; j < n; ++j)
        {
            line.push_back(0);
        }
        matrix.push_back(line);
    }

    for (int i = 0; i < n; ++i)
    {
        int vertex;
        int degree;

        cin >> vertex;
        cin >> degree;

        assert(vertex <= n);
        assert(degree <= n);

        for (int j = 0; j < degree; ++j)
        {
            int adj;
            cin >> adj;
            assert(adj <= n);
            matrix[vertex - 1][adj - 1] = 1;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            string delim = (j == (n - 1)) ? "\n" : " ";
            cout << matrix[i][j] << delim;
        }
    }

    return 0;
}

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

#define N 100

int main(void) {
    int n, u, k, v;
    int A[N + 1][N + 1] = {};
    
    cin >> n;
    
    for(int i = 0; i < n; ++i) {
        cin >> u >> k;
        for(int j = 0; j < k; ++j) {
            cin >> v;
            A[u][v] = 1;
        }
    }
    
    for(int i = 1; i <= n; ++i) {
        cout << A[i][1];
        for(int j = 2; j <= n; ++j) {
            cout << ' ' << A[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;j < n;j++){
      if(j) cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int mat[n][n];
    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 id;
        cin >> id;
        int k;
        cin >> k;
        int v;
        for(int j = 0; j < k; ++j){
            cin >> v;
            mat[id-1][v-1] = 1;
        }
    }
    for(auto x : mat){
        for(int i = 0; i < n; ++i){
            if(i == 0){
                cout << x[i];
            } else {
                cout << ' ' << x[i];
            }
        }
        cout << endl;
    }
}

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

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

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

int main(int argc, char const *argv[])
{
    // 頂点数
    int cnt_vertex(0);

    cin >> cnt_vertex;
    vector<vector<int>> vecGraph(cnt_vertex,vector<int>(cnt_vertex,0));

    int num_vertex(0), cnt_exit_vertex(0);

    for (int i = 0; i < cnt_vertex; i++)
    {
        cin >> num_vertex >> cnt_exit_vertex;
        int num_next_vertex(0);
        for (int j = 0; j < cnt_exit_vertex; j++)
        {
            cin >> num_next_vertex;
            // cout << endl;
            // cout << cnt_vertex << endl;
            vecGraph[i][num_next_vertex-1] = 1;
        }
    }

    for (int i = 0; i < cnt_vertex; i++)
    {
        for (int j = 0; j < cnt_vertex; j++)
        {
            if(j == cnt_vertex-1) {
                cout << vecGraph[i][j] << "\n";
            } else {
                cout << vecGraph[i][j] << " ";
            }
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
 int dp[200][200] = {0};

 void pgraph(int n){
      for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout << dp[i][j];
      if(j != n)cout << " ";
    }
    cout << endl;
  }

 }
int main(){
  int n,u,k;
  int ad;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      dp[u][ad] = 1;
    }
  }
  pgraph(n);
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin>>N;
    vector<vector<int>> G(N,vector<int>(N));
    for(int i=0;i<N;i++){
        int u,k; cin>>u>>k;
        u--;
        while(k--){
            int v; cin>>v;
            v--;
            G[u][v]=1;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cout<<G[i][j]<<(j==N-1? '\n':' ');
        }
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

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