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<cstdio>
int m[101][101];

int main(){
	int i,n,j,k,u,v;
	scanf("%d",&n);
	v = n;
	while(n--){
		scanf("%d",&u);
		scanf("%d",&j);
		while(j--){
			scanf("%d",&i);
			m[u][i] = 1;
		}
	}
	for( i = 1; i <= v; i++ ){
		for( j = 1; j <= v; j++ ){
			if(j!=1) printf(" ");
			printf("%d",m[i][j]);
		}
		printf("\n");
	}
}

C++: #include<cstdio>


int main(){
    int n,u,k,v;
    scanf("%d",&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 = 0;i < n;++i){
        scanf("%d %d",&u,&k);
        for(int j = 0;j < k;++j){
            scanf("%d",&v);
            G[u][v] = 1;
        }
    }
    for(int i = 1;i <= n;++i){
        for(int j = 1;j <n;++j){
            printf("%d ",G[i][j]);
        }
        printf("%d\n",G[i][n]);
    }
}

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

const static int N = 100;

int main() {
  int n, G[N][N];
  
  cin >> n;

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

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

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

  return 0;    
}

C++: 

#include <iostream>
using namespace std;

int main(){
        int n,m,l,i,j;
        cin >> n;
        int f[100][100] =
        for ( i = 0; i < n; i++){
                cin >> m;
                for ( j = 0; j < m; j++){
                        cin >> l;
                        f[m][l] = 1;
                }
        }
        for ( i = 0; i < n; i++){
                for ( j = 0; j < n-1; j++){
                        cout << f[i][j] << " ";
                }
                cout << f[i][n] << endl;
        }
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> adj(n, std::vector<int>(n, 0));
    for(int i=0;i<n;i++){
        int unused, k;
        std::cin >> unused >> k;
        for(int j=0;j<k;j++){
            int p;
            std::cin >> p;
            adj[i][p-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            std::cout << adj[i][j];
            if(j==(n-1)) std::cout << "\n";
            else std::cout << " ";
            
        }
    }
    return 0;
}

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

int main(void) {
	int n, i, j;
	int u, k, v;
	cin >> n;
	int G[n+1][n+1];
	for (i = 1; i <= n; i++) {
		for (j = 0; j <= n; j++) {
			G[i][j] = 0;
		}
	}
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		while (k--) {
			cin >> v;
			G[u][v] = 1;
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			if (j != 1) cout << " ";
			cout << G[i][j];
		}
		cout << 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;

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>
#include <vector>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<vector<int>> matricies(n, vector<int>(n, 0));
	while(n--) {
		int u, k;
		cin >> u >> k;
		while(k--) {
			int v;
			cin >> v;
			matricies.at(u-1).at(v-1) = 1;
		}
	}

	for (int i = 0; i < matricies.size(); i++) {
		for (int j = 0; j < matricies.at(0).size(); j++) {
			if (j == matricies.at(0).size() - 1) cout << matricies.at(i).at(j) << endl;
			else cout << matricies.at(i).at(j) << " ";
		}
	}
}

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

using namespace std;

int main(void){

  int graph[100][100];
  for( int i = 0 ; i < 100 ; i++ )
    for( int j = 0 ; j < 100 ; j++ )
      graph[i][j] = 0;

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

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

int n, u, k, v;
int g[101][101];

int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; ++j) {
            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++: #define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100
//#define MAX_ 1000
int time = 0;
int main(void)
{
	int G[MAX][MAX] = { false };
	int n, u, k, v;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d", &u, &k);
		for (int j = 0; j < k; ++j) {
			scanf_s("%d", &v);
			G[u - 1][v - 1] = true;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (j != 0) printf(" ");
			printf("%d", G[i][j]);
		}
		if (i != n - 1) printf("\n");
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, k[102], v[101][102] = {0}, i, j, l, a;

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

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (k[i] == 0) {
        for (l = v[i][j - 1]; l < n - 1; l++) {
          cout << "0 ";
        }
        cout << "0\n";
        break;
      }
      else {
        if (v[i][j] != 0) {
          k[i]--;
          for (l = v[i][j - 1]; l < v[i][j] - 1; l++) {
            cout << "0 ";
          }
          if (v[i][j] == n) {
            cout << "1\n";
            break;
          }
          else {
            cout << "1 ";
          }
        }
      }
    }
  }

  return 0;
}