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

bool mat[101][101] = {{false}};

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int m = 0; m != n; ++m){
        int i = 0, k = 0;
        cin >> i;
        cin >> k;
        while (k--){
            int j = 0;
            cin >> j;
            mat[i - 1][j - 1] = true;
        }
    }
    
    for (int i = 0; i != n; ++i){
        cout << mat[i][0];
        for (int j = 1; j != n; ++j){
            cout << ' ' << mat[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];
    int x;
    cin >> x;
    k[u[i]-1]+=x;

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<4; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=3)
        cout << " ";
      }
    }
  }

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	int i, j, k, n, n2;
	int m[100][100] = { 0 };
	int list[400][400] = { 0 };

	cin >> n;
	for (i = 0; i<n; i++) {
		cin >> n2;
		cin >> n2;
		list[i][0] = n2;
		for (j = 1; j <= n2; j++) {
			cin >> list[i][j];
		}
	}
	//cout << endl;
	
	for(i=0; i<n; i++){
		n2=list[i][0];
		for(j=1; j<=n2; j++){
			//cout << list[i][j] << " ";
			m[i][list[i][j] - 1] = 1;
		}
		//cout << endl;
	}
	//cout << endl; cout << endl;
	

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cout << m[i][j];
			if (j != (n - 1)) cout << " ";
		}
		cout << endl;
	}
	//cout << endl; cout << endl;

	return 0;
}

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

int main(){

  int n;

  cin >> n;

  int c[n][n];

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

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

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(j == 0) cout << c[i][j];
      else cout << " " << c[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#define N 105
using namespace std;
int n,u,k,v,M[N][N];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int i=0;i<k;i++)
      cin>>v,M[u-1][v-1]=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<cstdio>

using namespace std;

int main() {
	int n;
	int M[1000][1000];
	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;
			M[u][v] = 1;
			//cout << M[u][v];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
		    if( j != n){
		        cout << M[i][j]<< " " ;
		    }
		    else{
		        cout << M[i][j];
		    }
			
		}
		cout << endl;
	}
	
	//cout << endl;

	return 0;
}

C++: #include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	ll d[100][100];
	REP(i, n) REP(j, n) d[i][j] = 0;
	REP(i,n)
	{
		cin >> w >> k;
		REP(j, k) {
			cin >> h;
			d[i][h - 1] = 1;
		}
	}
	
	REP(i, n) {
		REP(j, n)
		{
			cout << ' ' << d[i][j];
		}
		cout << endl;
	}
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int main(int argc, char const *argv[]) {
	int N;
	cin >> N;
	std::vector<vector<int> > G(N, vector<int>(N));
	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) {
			cout << G[i][j];
			if (j != N - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

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


int main(){

	int adjMar[MAX][MAX];
	int n, i, j, vertice, degree, adjVertice;
	cin >> n;

	for (i = 0; i <= n; i++)
		for (j = 0; j <= n; j++)
			adjMar[i][j] = 0;

	for (i = 1; i <= n; i ++) {
		cin >> vertice;
		cin >> degree;
		for (j = 0; j < degree; j++){
			cin >> adjVertice;
			adjMar[vertice][adjVertice] = 1;
		}
	}

	for (i = 1; i <= n; i++){
		for (j = 1; j <= n; j++){
			cout << adjMar[i][j];
			if (j != n) 
				cout <<' ';
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

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

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

    vector<int> row(n, 0);
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;

      row[v-1] = 1;
    }

    // output
    cout << row[0];
    for (int j = 1; j < n; j++) {
      cout << " " << row[j];
    }
    cout << eol;
  }
  
  return 0;
}