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<bits/stdc++.h>
using namespace std;
#define MAXN 102
int G[MAXN][MAXN];
int main(){
    int n;
    cin >> n;
    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++){
            cout << G[i][j] << ' ';
        }
        cout << G[i][n] << endl;
    }
    for(int j = 1; j < n; j++){
        cout << G[n][j] << ' ';
    }
    cout << G[n][n];
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
static const int MAX  = 101;
int main ()
{
  int n,u,k,v;
  cin>>n;
  int M[MAX][MAX];
  for(int i  = 1;i<=n;i++)
    {
      for(int j = 1;j<=n;j++)
        {
          M[i][j] = 0;
        }
    }
  for(int i = 1;i<=n;i++)
   {
     cin>>u>>k;
     for(int j = 1;j<=k;j++)
       {
         cin>>v;
         M[u][v] = 1;
       }
   }
   for(int i = 1;i<=n;i++)
     {
       for(int j = 1;j<=n;j++)
        { if(j-1) cout<<" ";
          cout<<M[i][j];
     }
     cout<<endl;
   }
  return 0 ;
}

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

int n;
int k;


int main(){
  int num;
  cin>>n;
  int adj[n][n];
  int rin;
  int i=0,j=0;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    cin>>num>>k;
    num--;
    for(j=0;j<k;j++){
      cin>>rin;
      rin--;
      adj[num][rin]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<adj[i][j];
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
        int n, u, k, v;
        int g[100][100];

        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> u >> k;
                if (k > 0) {
                        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 <bits/stdc++.h>
using namespace std;

using P = pair<int,int>;

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

C++: #include <bits/stdc++.h>
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>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

void to_adjacent_matrix(vector<vector<int>>& adjacent_list, vector<vector<int>>& adjacent_matrix);

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

    string line;
    getline(cin, line); // skip first newline character

    vector<vector<int>> vertex(n, vector<int>(n, -1));
    for (int i = 0; i < n; ++i) {
        getline(cin, line);

        string tmp;
        stringstream ss(line);
        int j = 0;
        while (getline(ss, tmp, ' ')) {
            if (j == 0) {
                ++j;
                continue;
            }

            vertex[i][j - 1] = stoi(tmp);
            ++j;
        }
    }

    vector<vector<int>> adjacent(n, vector<int>(n, 0));
    to_adjacent_matrix(vertex, adjacent);

    for (int i = 0; i < n; ++i) {
        cout << adjacent[i][0];
        for (int j = 1; j < n; ++j)
            cout << ' ' << adjacent[i][j];
        cout << '\n';
    }
}

void to_adjacent_matrix(vector<vector<int>>& adjacent_list, vector<vector<int>>& adjacent_matrix)
{
    int n = adjacent_list.size();

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n && adjacent_list[i][j] != -1; ++j) {
            int adjacent = adjacent_list[i][j] - 1;
            if (adjacent <= 0 || adjacent > n)
                continue;

            adjacent_matrix[i][adjacent] = 1;
        }
    }
}

C++: #include <stdio.h>
 
int map_max;
int map[110][110];
int rows;
int cols[110];
int mat[110][110] = {};
 
void get_map();
void print_map();
void conv_map();
void print_mat();
 
int main()
{
 
  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}
 
void get_map()
{
 
  int k;
  scanf("%d", &map_max);//<100
 
  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
    {
      scanf("%d", &map[i][j]);
    }
    }
 
   
  return ;
}
 
void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      printf("%d", map[i][j]);
    }
      puts("");
    }
return ;
}
 
 
void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      mat[i][map[i][j]-1]=1;
    }
    }
  return ;
}
 
void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
    {
      printf("%d", mat[i][j]);
      if(j!=map_max-1)
        {
          printf(" ");
        }
    }
      if(i!=map_max-1)
    {
      printf("\n");
    }
    }
}

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

int main(){
  int n;
  cin >> n;
  int u, k, v, adj[MAX+1][MAX+1];

  // init
  for ( int i = 1; i <= n; i++){
    for ( int j = 1; j <= n; j++){
      adj[i][j] = 0;
    }
  }

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

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

  return 0;
}

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

      else
        cout << 0;

      if(j!=k[i]-1)
        cout << " ";
      }
      cout << endl;
    }
  }