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,k, u, v;

  cin >> n;
  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;
   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];
      if(j!= n-1){
       cout<<" ";
     }
   }
   cout << endl;
 }

 return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int> > graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(n);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            graph[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
        int value;
        for(int j=0;j<k;j++){
            scanf("%d",&value);
            graph[u-1][value-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            printf("%d ",graph[i][j]);
        }
        if(i!=n-1) {
            printf("\n");
        }
    }

    return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int mat[n][n] = {};
    for(int i = 0; i < n; ++i){
        int id;
        cin >> id;
        int k;
        cin >> k;
        int v;
        for(int j = 0; j < k; ++j){
            cin >> v;
            mat[id-1][v-1] = 1;
        }
    }
    for(auto x : mat){
        for(int i = 0; i < n; ++i){
            if(i == 0){
                cout << x[i];
            } else {
                cout << ' ' << x[i];
            }
        }
        cout << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll n;
  cin >> n;
  vector<vector<ll>> vec(n,vector<ll>(n,0));
  ll u,k,v;
  rep(i,n){
    cin >> u >> k;
    rep(j,k){
      cin >> v;
      vec[u-1][v-1] = 1;
    }
  }

  rep(i,n){
    rep(j,n){
      cout << vec[i][j];
      if(j != n-1){
        cout << " ";
      }
    }
    cout << endl;
  }
}

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

int main(){
        int N;
        cin >> N;
        int a[110][110]={{0}};
        for(int i=0; i<N; i++){
                int v,n;
                cin >> v;
                cin >> n;
                for(int j=0; j<n; j++){
                        int V;
                        cin >> V;
                        a[v-1][V-1]=1;
                }
        }
        for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                        cout << a[i][j];
                        if(j<N-1)cout << " ";
                }
                cout << endl;
        }
}

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

int main() {
  int N, u, k, v;
  int A[100][100];

  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j) {
      A[i][j] = 0;
    }
  }

  cin >> N;

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

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

  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

  int n,u,k,v,graph[106][106]={{}};

  cin >> n ;

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

  for(int i = 1; i<= u; i++){
    for(int j = 1; j<= u; j++){
      cout << graph[i][j] << ' ' ; 
    }
    cout << endl;
  }


  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int a[101][101];
	memset(a,0,sizeof(a));
	cin>>n;
	int u,k;
	for(int i = 0;i < n;i++){
		cin>>u>>k;
		u--;
		for(int j=0;j<k;j++){
			int x;
			cin>>x;
			x--;
			a[u][x]=1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j)cout<<" ";
			cout<<a[i][j];
		}
		cout<<endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    bool A[105][105];
    for(int i=0; i<105; i++){
        for(int j=0; j<105; j++){
            A[i][j] = 0;
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        int u;
        int k;
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            int v;
            cin >> v;
            v--;
            A[u][v] = 1;
        }
        
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n-1; j++){
            cout << A[i][j] << " ";
        }
        cout << A[i][n-1] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n][n] = {0};
    rep(i,n){
        rep(j,n){
            a[i][j]=0;
        }
    }
    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        rep(j, k)
        {
            int hoge;
            cin >> hoge;
            a[u-1][hoge-1] = 1;
        }
    }
    rep(i, n)
    {
        rep(j, n)
        {
            cout << a[i][j];
            if (j != n - 1)
                cout << " ";
        }
        cout << endl;
    }
}

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

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

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