Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

bool adj[105][105];

int main()
{
	memset (adj, false, sizeof (adj ) );

	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	rep (i, n ){
		int v, k;
		cin >> v >> k;
		rep (j, k ){
			int u; cin >> u;
			adj[v][u] = true;
		} // end rep
	} // end rep
	
	for (int i = 1; i <= n; i++ )
		for (int j = 1; j <= n; j++ )
			cout << (adj[i][j] ? 1 : 0) << (j != n ? ' ' : '\n' );
	
	
	return 0;
}

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

const int MAX = 110;
int mat[MAX][MAX];

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      cout << mat[i][j] << (j==n-1?'\n':' ');
  }
  return EXIT_SUCCESS;
}

C++: #include <bits/stdc++.h>
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;
    u--;
    for(int j=0;j<k;j++) {
      int v;
      cin >> v;
      v--;
      a[u][v]++;
    }
  }
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      if(j) cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100],v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i] >> k[i];

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<4; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=3)
        cout << " ";
      }
      cout << endl;
    }
  }

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

//---------------------------------------------------------------
// ------ graph ------ //
using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
void add_edge1(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
}
void add_edge2(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
}
//---------------------------------------------------------------

int main() {
    int n; cin >> n;
    Matrix M(n, Array(n, 0));
    for (int i = 0; i < n; i++) {
        int u, k; cin >> u >> k;
        while (k--) {
            int v; cin >> v; M[u - 1][v - 1]++;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << M[i][j] << " \n"[j == n - 1];
        }
    }
    return 0;
}

C++: /* 
 * ALDS1_11.cpp
 * ??£??\???????????¨?????§???????????????????????°??????G?????£??\????????¨?????????????????????????????????
 */
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

using Adjacents = vector<int>;
using Vertexes = vector<Adjacents>;

int main(void) {

    int N;
    scanf("%d", &N);

    Vertexes vs;
    vs.resize(N);
    for (int i = 0, id, num; i < N; ++i) {
        scanf("%d %d", &id, &num);
        for (int j = 0, vert; j < num; ++j) {
            scanf("%d", &vert);
            vs[id-1].push_back(vert);
        }
    }

    int **matrix = new int*[N];
    for (int i = 0; i < N; ++i) {
        matrix[i] = new int[N];
        memset(matrix[i], 0, sizeof(int)*N);
        for (int j = 0; j < vs[i].size(); ++j) {
            matrix[i][vs[i][j] - 1] = 1;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            //printf("%2d", matrix[i][j]);
            putchar(matrix[i][j] + '0');
            if (j != N - 1)
                putchar(' ');
        }
        delete[] matrix[i];
        printf("\n");
    }
    delete[] matrix;

    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int G[101][101];
int main(){
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;
G[u][v]=1;
}
}
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
	cout<<G[i][j];
	(j==n)?cout<<endl:cout<<" ";
	}
}
return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int adjacency_matrices[n][n];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            adjacency_matrices[i][j] = 0;
    int vertex;
    int degree;
    for(int i = 0; i < n; i++)
    {
        cin >> vertex;
        cin >> degree;
        int to_v;
        for(int j = 0; j < degree; j++)
        {
            cin >> to_v;
            adjacency_matrices[vertex - 1][to_v - 1] = 1;
        }
    }

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

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

int a[101][101] = {0}; //???????????????u??¨u?????£??\?????????????????????v  u??????v???????????£???????????°1

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

  int u,k,v;
  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++) {
    for(int j = 1; j <= n; j++) {
      cout << a[i][j];

      cout << " ";
    }
    cout <<  endl;
  }
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int i;
  int a[150][150];
  int x,y;
  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      a[x][y]=0;
    }
  }

  for (i = 0; i < n; i++) {
    int l;
    cin >> l;
    int k;
    cin >> k;
    int j;
    for (j = 0; j < k; j++) {
      int m=0;
      cin >> m;
      a[l-1][m-1]=1;
    }

  }

  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      printf("%d ",a[x][y]);
    }printf("?\n");
  }

  return 0;
}