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++: //ALDS1_11_A:Graph
#include <bits/stdc++.h>
using namespace std;
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

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

C++: #include<iostream>
using namespace std;
int main() {
    bool f[100][100];
    for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)f[i][j] = false;
    int n, u, k, v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            f[u - 1][v - 1] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j)cout << " ";
            cout << f[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

void InputSet(std::vector<int> & a) {
	int n;
	cin >> n;
	a.resize(n,0);
	for(int i=0;i<n;++i) {
		cin >> a.at(i);
		a.at(i)--;
	}
}
int main(){
	//u k v1 v2 ... vk
	int n;
	cin >> n;
	vector<vector<int> > Ad;
	Ad.resize(n);
	for(int k=0;k<n;++k) {
		int u;
		cin >> u;
		--u;
		InputSet(Ad[u]);
	}
	for(int i=0;i<n;++i){
		string a(n,'0');
		for(int j=0;j<(int)Ad[i].size();++j){
			a.at(Ad[i][j]) = '1';
		}
		for(int j=0;j<n;++j){
			if(j==0){
				cout << a[j];
			} else  {
				cout << " " << a[j];
			}
		}
		cout << endl;
	}
}

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

using namespace std;

int N;

int main()
{
	cin >> N;

	vector<vector<bool> > M(N, vector<bool>(N));

	int u, k, v;

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

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

			M[u - 1][v - 1] = true;
		}
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N;)
		{
			cout << M[i][j];

			if (j++ != N)
			{
				cout << ' ';
			}
		}

		cout << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> vec(n, vector<int>(n, 0));
    rep(i, n) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int v;
            cin >> v;
            vec[i][--v] = 1;
        }
    }
    rep(i, n) rep(j, n) {
        if (j != n - 1) cout << vec[i][j] << " ";
        else cout << vec[i][j] << endl;
    }
    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++){
            if(i) cout << " ";
            cout<<A[i][j];
        }
        cout<<endl;
    }
    
//    std::cout << "Hello, World!\n";
    return 0;
}

C++: #include <iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N];
	int n, u, k, v, i, j;

	cin >> n;

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

	for ( i = 0; i < n; i++ ) {
		cin >> u >> k;
		u--;
		for ( j = 0; j < k; j++ ) {
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

	for ( i = 0; i < n; i++ ) {
		for ( j = 0; j < n; j++ ) {
			if( j ) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

int main()
{
	int n, k, u, v;
	cin >> n;
	// N * N matrix filled with 0
	vector< vector<int> > mat(n, vector<int>(n, 0));

	for(int i=0; i<n; i++){
		cin >> u >> k;
		// adjust 0 origen
		u--;
		for(int j=0; j<k; j++){
			cin >> v;
			//cout << "vertex: " << v << '\n';
			// adjust 0 origen
			v--;
			mat[u][v] += 1;
		}
		//cout << '\n';
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			printf("%d ", mat[i][j]);
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int a[101][101] = {}; //???????????????u??¨u?????£??\?????????????????????v  u??????v???????????£???????????°1
  int n;
  cin >> n;

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

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      cout << a[i][j];

      if(j != n) cout << " ";
    }
    cout <<  endl;
  }
  return 0;
}

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)
#define REP(i, first, to) for(ll i = first; i <= to; ++i)

using namespace std;
typedef long long ll;

list<int> from[101];
int to[101][101];
int n;
void solve() {
	cin >> n;
	rep(i, 0, n) {
		int u, k;
		cin >> u >> k;
		rep(j, 0, k) {
			int value;
			cin >> value;
			from[u].push_back(value);
		}
	}
	REP(i, 1, n) {
		while(!from[i].empty()) {
			to[i][from[i].front()] = 1;
			from[i].pop_front();
		}
	}
	REP(i, 1, n) {
		REP(j, 1, n) {
			if (j == n) {
				cout << to[i][j] << endl;
			} else {
				cout << to[i][j] << " ";
			}
		}
	}
}

int main() {
	solve();
	return 0;
}

C++: #include <cstdio>
#define N 100
int main(){
    int M[N][N];
    int n,u,k,v;
    scanf("%d\n",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)M[i][j]=0;
}
  for(int i=0;i<n;i++){
   scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
       scanf("%d",&v);
        v--;
        M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(j)printf(" ");
       printf("%d",M[i][j]);
    }
   printf("\n");
  }
  return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int n;
typedef vector<vector<int> > AdjMatrix;
AdjMatrix graph;


int main()
{
    int u,k,v;
    cin >> n;
    graph = AdjMatrix(n, vector<int>(n, 0));
    REP(i,n){
        cin >> u >> k;
        REP(j,k){
            cin >> v;
            graph[u-1][v-1] = 1;
        }
    }


    REP(i, n){
        REP(j, n){
            cout << graph[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

int main()
{
	int n;
	int v[100][100];

	cin >> n;

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

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

		cin >> u >> k;

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

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

	return 0;
}