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 rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> mat(N, vector<int>(N, 0));
    rep(i, 0, N) {
        int id, deg;
        cin >> id >> deg;
        id--;
        rep(j, 0, deg) {
            int u;
            cin >> u;
            u--;
            mat[id][u] = 1;
        }
    }

    rep(i, 0, N) rep(j, 0, N) {
        cout << mat[i][j] << (j < N - 1 ? " " : "\n");
    }
}

C++: #include<stdio.h>

int main(){
  int i,j,n,k,c,b;

  int a[124][124]={{}};

  scanf("%d",&n);
  for(i=0;i<n;i++){

    scanf("%d %d",&c,&b);
    for(j=0;j<b;j++){
      scanf("%d",&k);
      a[c-1][k-1]=1;

    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0){
	printf(" ");
      }
       printf("%d",a[i][j]);
    
    }
    
    puts("");
 
}
  return 0;
}

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


int main(int argc, char const *argv[]) {
  int n; // .. 100
  std::cin >> n;


  std::vector<std::vector<bool> > adj(n, std::vector<bool>(n));

  for(int q=0; q<n; ++q){
    int i_plus_1, k;
    std::cin >> i_plus_1;
    std::cin >> k;
    for(int p=0; p<k; ++p){
      int j_plus_1;
      std::cin >> j_plus_1;
      adj[i_plus_1-1][j_plus_1-1] = true;
    }
  }

  for(int i=0; i<n; ++i){
      for(int j=0; j<n; ++j){
        std::cout  <<  adj[i][j] << ' '; 
      }
      std::cout << std::endl;
  }

  return 0;
}

C++: #include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t n; cin >> n;

    auto matrix = make_v(0, n, n);
    for (size_t i = 0; i < n; ++i) {
        size_t u, k; cin >> u >> k;
        u--;
        for (size_t j = 0; j < k; ++j) {
            size_t v; cin >> v;
            v--;
            matrix[u][v] = 1;
        }
    }

    for (size_t i = 0; i < n; ++i) {
        for (size_t j = 0; j < n; ++j) {
            cout << matrix[i][j] << (j == n - 1)[" \n"];
        }
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	int u,k;
	int v[k];
	int G[N][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>>u>>k;
		for(int j=0;j<k;++j){
			cin>>v[j];
			G[u-1][v[j]]=1;  //??£??\????????????ID??§??????"u"???1???????§????????????§?????????????????????u-1??¨??????
		}	
	}
        for(int i=0;i<N;++i){
       for(int j=0;j<N;++j){
cout <<G[j][i]<< " ";
}cout<<endl;
}
}

C++: #include<iostream>
using namespace std;
bool g[114][514];
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k; cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v; cin >> v;
			g[u][v] = true;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j != 1)cout << ' ';
			cout << g[i][j];
		}
		cout << endl;
	}
}

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


int main(){
    int n;
    cin>>n;
    
    vector<vector<int>> a(n,vector<int> (n,0));
    
    vector<vector<int>> v(n,vector<int> (n));
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            int m;
            cin>>m;
            a.at(u-1).at(m-1)=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            cout<<a.at(i).at(j)<<" ";
        }
        cout<<a.at(i).at(n-1)<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main() {
  int n; cin >> n;
  vector<vector<int>> M(n, vector<int>(n));
  rep(i, n) {
    int u, k; cin >> u >> k;
    rep(z, k) {
      int num; cin >> num;
      M.at(i).at(num - 1) = 1;
    }
  }
  rep(i, n){
    rep(j, n-1)cout << M.at(i).at(j) << " ";
    cout << M.at(i).at(n-1) << endl;
  }
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
    vector<int> l[101];
    int matrix[100][100];
    int n;
    cin>>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;
            l[u].push_back(tmp);
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            matrix[i][j]=0;
        }
    }
    
    for(int i=1;i<n+1;i++)
    {
        for(int j=0;j<l[i].size();j++)
        {
            matrix[i-1][l[i][j]-1]=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;
    }
}

C++: #include<iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    int G[N][N]={};
    for(int i=0;i<N;++i){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;++j){
            int v;
            cin>>v;
            G[u-1][v-1]=1;
        }
    }
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(j) cout<<' ';
            cout<<G[i][j];
        }
        cout<<endl;
    }
}

C++: #include <iostream>
using namespace std;
int adj[100][100] = {0};
int main()
{
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		int j, k;
		cin >> j >> k;
		j--;
		for (int m=0;m<k;m++) {
			int a;
			cin >> a;
			a--;
			adj[j][a]=1;
		}
	}

	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			cout << adj[i][j];
			cout << ' ';
	//		if (j<n) cout << ' ';
		}
	//	cout << endl;
	}
		
	return 0;
}