Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	for i := 0; i < num; i++ {
		sc.Scan()
		sc.Text()
		sc.Scan()
		num2, _ := strconv.Atoi(sc.Text())
		r := make([]int, num)
		for j := 0; j < num2; j++ {
			sc.Scan()
			val, _ := strconv.Atoi(sc.Text())
			r[val-1] = 1
		}
		for i, v := range r {
			if i != 0 {
				fmt.Printf(" %v", v)
			} else {
				fmt.Printf("%v", v)
			}
		}
		fmt.Println()
	}
}

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

struct Edge {
  int source, target;
  Edge(int source, int target): source(source), target(target) {}
};

struct Node {
  std::vector<Edge> edges;
  void addEdge(Edge edge) {
    edges.push_back(edge);
  }
};

class Graph {
private:
  std::vector<Node> nodes;
  int size;
public:
  Graph(int size): size(size) {
    nodes.resize(size);
  }
  void addEdge(int source, int target) {
    nodes[source].addEdge(Edge(source, target));
  }
  void printAdjacencyList() {
    for(Node node: nodes) {
      std::vector<int> hasEdgeTo(size);
      for(Edge edge: node.edges) {
        hasEdgeTo[edge.target] = 1;
      }
      for(auto i: hasEdgeTo) {
        std::cout << i << ' ';
      }
      std::cout << std::endl;
    }
  }
};

int main() {
  int n;
  std::cin >> n;
  Graph graph(n);
  for(int i = 0; i < n; i++) {
    int u, k;
    std::cin >> u >> k;
    for(int j = 0; j < k; j++) {
      int v;
      std::cin >> v;
      graph.addEdge(u - 1, v - 1);
    }
  }
  graph.printAdjacencyList();
}

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

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

C++: #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
 
 
int main()
{
	int matrix[100][100] = {0};
	int n;
	cin>>n;
	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--;
			matrix[u][v] = 1;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n;j++){
			if( j != 0) cout<<" ";
			cout<<matrix[i][j];
		}
		cout<<endl;
	}

	return 0;
}

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

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

    vector<vector<int>> M(N, vector<int>(N, 0));

    int u, k, v;
    for (int i = 0; i < N; i++)
    {
        cin >> u >> k;
        u--; // 0オリジンへ変更
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            v--; // 0オリジンへ変更
            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;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>

using namespace std;
int main() {
	int n,m,l,p;
	cin >> n;
	bool 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 >> m;
		cin >> l;
		for(int j = 0; j < l;j++) {
			cin >> p;
			a[m-1][p-1] = 1;
		}
	}
	for ( int i = 0;i < n;i++) {
		for(int j= 0; j < n;j++) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

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

int main ()
{
    int N;
    cin >> 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, k;
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

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

    return 0;
}

C++: You are not allowed to see this code.

C++: #include <iostream>
using namespace std;
static const int N = 100;

int main(void)  {
  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 <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<vector<bool>> M(n, vector<bool>(n));
	for (int i = 0; i < n; i++) {
		int v, k;
		cin >> v >> k;

		for (int j = 0; j < k; j++) {
			int x;
			cin >> x;
			M.at(v - 1).at(x - 1) = true;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) cout << ' ';
			cout << M.at(i).at(j);
		}
		cout << endl;
	}
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int n; cin >> n;
  int G[n][n];
  FOR(i,0,n) FOR(j,0,n) G[i][j] = 0;
  FOR(i,0,n){
    int u,k;
    cin >> u >> k;
    u--;
    FOR(j,0,k){
      int v;
      cin >> v;
      v--;
      G[u][v] = 1;
    }
  }
  FOR(i,0,n){
    FOR(j,0,n){
      printf("%d%c", G[i][j], j == n - 1 ? '\n' : ' ');
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n; cin >> n;
  int graph[n][n] = {};
  int k,f;
  rep(i,n){
    cin >> f >> k;
    rep(j,k){
      int ai; cin >> ai;
      graph[i][ai-1] = 1;
    }
  }
  rep(i,n){
    rep(j,n){
      cout << graph[i][j];
      if(j != n-1) cout << " ";
    }
    cout << "\n";
  }
}

C++: #include <iostream>
using namespace std;
int G[101][101];
int n,v,k,p;
int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		cin >> v>>k;
		for(int j=0;j<k;j++){
			cin >> p;
			G[v][p]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			cout << G[i][j]<<" ";
		}
		cout << G[i][n]<<endl;
	}
}

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;
 
void main() {
	int Adj[100][100];
	int n, u, k, v;
	cin >> n;

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