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


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

C++: #include <iostream>

using namespace std;

const int MAX_V = 100;

int main ( void )
{
  int n;
  int E[MAX_V][MAX_V];

  cin >> n;

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

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

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

C++: //
//  main.cpp
//  graph
//
//  Created by ???????????? on 2017/10/22.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, i, j, id, num, node;
    scanf("%d", &n);
    int A[n][n];
    
    //initialize with 0
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            A[i][j] = 0;
        }
    }
    
    for (i = 0; i < n; i++){
        scanf("%d", &id);
        scanf("%d", &num);
        for(j = 0; j < num; j++){
            scanf("%d", &node);
            A[id-1][node-1] = 1;
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            cout<<A[i][j]<<" ";
        }
        cout<<endl;
    }
    
//    std::cout << "Hello, World!\n";
    return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    int ans[n][n];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans[i][j] = 0;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            ans[u-1][tmp-1] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j == n-1) cout << ans[i][j];
            else cout << ans[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; i<n; j++)
    {
      m[i][j]=0;
    }
  }

  for(int i=0; i<n; i++)
  {
    cin >> u >> k;
    u--;
    for(int j=0; i<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 << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>



using namespace std;

static const int N = 100;
int A[N+1][N+1];

int main(){
    
    for (int i=0;i<=N;i++){
        A[i][0] = 0;
    }
    for (int j = 0;j<=N;j++){
        A[0][j] = 0;
    }
    int n;
    cin >> n;
    for (int i=1;i<=n;i++){
        int p,k;
        cin >> p >> k;
        for (int j=0;j<k;j++){
            int a;
            cin >> a;
            A[i][a] = 1;
           
        }
    }

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

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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int n;
  cin >> n;
  vector<vector<int> > G;
  G.resize(n);
  for(int i = 0; i < n; i++){
    int u, k;
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      int tmp;
      cin >> tmp;
      G[i].push_back(tmp);
    }
  }
  for(int i = 0; i < n; i++){
    int k = 0;
    for(int j = 0; j < n; j++){
      if(G[i].size() != 0){
        if(G[i][k] == j + 1){
          cout << 1;
          k++;
        }else cout << 0;
      }else cout << 0;
      if(j != n - 1)cout << " ";
    }

      cout << endl;
      k = 0;
  }
}

C++: #define REP(i,n) for (int i=0;i<(n);i++)
#include <iostream>
using namespace std;
int main(){
        int n,u,k,v;
        cin >> n;
        int g[n][n];
        REP(i,n){
                REP(j,n){
                        g[i][j] = 0;
                }
        }
        REP(i,n){
                cin >> u >> k;
                REP(j,k){
                        cin >> v;
                        g[v-1][u-1] = 1;
                }
        }
        REP(i,n){
                REP(j,n){
                        cout << (j?" ":"") << g[j][i];
                }
                cout << endl;
        }
}

C++: #include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define INFTY 2000000001
#define MAX 101

int n = 0;
int adl[MAX][MAX], deg[MAX];
int adm[MAX][MAX];

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      adm[i][j] = 0;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int num;
    scanf("%d", &num);
    num--;
    scanf("%d", &deg[num]);
    for ( int j = 0; j < deg[num]; j++) {
      scanf("%d", &adl[num][j]);
      adl[num][j]--;
      adm[num][adl[num][j]] = 1;
    }
  }

  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      printf("%d ", adm[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

static const int MAX = 100;

int main(){
    int n;
    scanf("%d",&n);
    int u,k,adj[MAX][MAX],tmp;
    memset(adj,0,sizeof(adj));
    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(int m=0;m<k;m++){
            scanf("%d",&tmp);
            adj[u-1][tmp-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int m=0;m<n;m++){
            if(m) printf(" ");
            printf("%d",adj[i][m]);
            if(m==3) printf("\n");
        }
    }

    return 0;
}

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

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

  vector<vector<int>> g(n, vector<int>(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++) {
    int u, k;
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      a--;
      g[u][a] = 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;
  }
}