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

int main(){
  int n;
  cin >> n;
  int mat[n + 1][n + 1];

  for(auto i = 0; i < n + 1; i++){
    for(auto j = 0; j < n + 1; j++){
      mat[i][j] = 0;
    }
  }

  for(auto i = 1; i <= n; i++){
    int vertex, dimout;
    cin >> vertex >> dimout;

    vector<int> adjvertices(dimout);
    for(auto j = 0; j < dimout; j++){
      cin >> adjvertices[j];
      mat[vertex][adjvertices[j]] = 1;
    }
  }

  for(auto i = 1; i <= n; i++){
    for(auto j = 1; j <= n; j++){
      cout << mat[i][j];
      if(j != n) cout << " ";
    }
    cout << endl;
  }
}

C++: #include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int main() {
	int point;
	cin >> point;
	vector<queue<int> >lis(point);
	for (int i = 0;i < point;i++) {
		int V,edges;
		cin >> V>>edges;
		for (int j = 0;j < edges;j++) {
			int h;
			cin >> h;
			lis[i].push(h-1);
		}
	}

	vector<vector<int> > v(point, vector<int>(point, 0));
	for (int i = 0;i < point;i++) {
		while (!lis[i].empty()) {
			int j = lis[i].front();
			lis[i].pop();
			v[i][j] = 1;
		}
	}
	for (int i = 0;i < point;i++) {
		for (int j = 0;j < point;j++) {
			cout << v[i][j]<<" ";
		}
		cout << endl;
	}

	return 0;
	
}

int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    int n;
    bool g[101][101] = {};
    cin >> n;
    rep(i,n) {
        int u,k;
        cin  >> u >> k;
        rep(j,k) {
            int tmp;
            cin >> tmp;
            g[u][tmp] = 1;
        }
    }
    FOR(i,1,n+1) {
        FOR(j,1,n+1) {
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
	return 0;
}

C++: 
#include <iostream>

using namespace std;

int a[110][110];

int main(){
    int N;
    cin >> N;
    for(int i = 0;i < N;i++){
        int n,k;
        cin >> n >> k;
        for(int j = 0;j < k;j++){
            int l;
            cin >> l;
            a[i][l-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 a[100][100] = {};
  int n, k, idx, v;
  cin >> n;
  for(int i = 0; i < n; ++i) {
	cin >> idx >> k;
	for(int j = 0; j < k; ++j) {
	  cin >> v;
	  a[i][v - 1] = 1;
	}
  }

  for(int i = 0; i < n; ++i) {
	for(int j = 0; j < n; ++j) {
	  cout << a[i][j];
	  cout << (j < n - 1 ? " " : "\n");
	}
  }
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<vector<int>>a(n,vector<int>(n,0));
  for(int i=0;i<n;i++){
    int num;
    cin>>num;
    num--;
    int m;
    cin>>m;
    for(int j=0;j<m;j++){
      int x;
      cin>>x;
      x--;
      a[num][x]++;
    }
  }
  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;
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int minimum=-1;


int main(){
	int n,row,num,col;
	scanf("%d",&n);
	int table[n][n];
	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++){
			table[i][k] = 0;
		}
	}

	for(int i=0;i<n;i++){
		scanf("%d %d",&row,&num);
		for(int k=0;k<num;k++){
			scanf("%d",&col);
			table[row-1][col-1]=1;
		}
	}

	for(int i=0;i<n;i++){
		for(int k=0;k<n-1;k++){
			printf("%d ",table[i][k]);
		}
		printf("%d\n",table[i][n-1]);
	}

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int M[N][N];

int main() {
	int n; cin >> n;
	rep(i, n) rep(j, n) M[i][j] = 0;
	rep(i, n) {
		int _n, n2; cin >> _n >> n2;
		rep(j, n2) {
			int k; cin >> k;
			M[i][k-1] = 1;
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (j < n-1) cout << M[i][j] << ' ';
			else cout << M[i][j];
		}
		cout << endl;
	}
}