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.cpp
// Graph I - Graph

#include <iostream>
#include <vector>
using namespace std;

void print(vector<vector<int>> &A, int n)
{
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
}

int main()
{
    int n;
    cin >> n;
    int id;
    int num;
    vector<vector<int>> A(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> id >> num;
        if (num == 0) continue;
        else {
            int tmp;
            for (int j = 0; j < num; j++) {
                cin >> tmp;
                A[id - 1][tmp - 1] = 1;
            }
        }
    }

    print(A, n);

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;


int main(void){
  int n,a,b,c;
  cin >> n;
  int v[n][n];
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<b;j++){
      cin >> c;
      v[a-1][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i][j]!=1)cout << 0 << ' ';
      else cout << v[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

#define N 100

int main()
{
	int m[N][N] = {0};
	
	int n;	cin >> n;

	int v, in, out;
	for (int i = 0; i < n; ++i)
	{
		cin >> in >> v;
		for (int j = 0; j < v; ++j)
		{
			cin >> out;
			m[in - 1][out - 1] = 1;
		}
	}

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

	return 0;
}

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

int main() {
	int n,u,k,v;
	int i,j;
	vector<vector<int> > V;
	scanf("%d",&n);
	V.resize(n);
	for(i=0; i<n; ++i) {
		V[i].resize(n);
		for(j=0; j<n; ++j) {
			V[i][j]=0;
		}
	}
	for(i=0; i<n; ++i) {
		scanf("%d%d",&u,&k);
		for(j=0; j<k; ++j) {
			scanf("%d",&v);
			V[u-1][v-1]=1;
		}
	}
	for(i=0; i<n; ++i) {
		for(j=0; j<n-1; ++j) {
			printf("%d ",V[i][j]);
		}
		printf("%d\n",V[i][n-1]);
	}
	return 0;
}

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

using namespace std;

class Vertex
{
public:
    int number_of_edges;
    vector<int> edges;
};

int main()
{
    int n;
    cin >> n;

    vector<Vertex> adjacency_list(n);
    for (int i = 0; i < n; ++i) {
        int index;
        cin >> index >> adjacency_list[i].number_of_edges;

        adjacency_list[i].edges.resize(adjacency_list[i].number_of_edges);
        for (int j = 0; j < adjacency_list[i].number_of_edges; ++j)
            cin >> adjacency_list[i].edges[j];
    }

    vector<vector<int>> adjacency_matrix(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < adjacency_list[i].number_of_edges; ++j)
            adjacency_matrix[i][adjacency_list[i].edges[j] - 1] = 1;
    }

    for (int i = 0; i < n; ++i) {
        cout << adjacency_matrix[i][0];
        for (int j = 1; j < n; ++j)
            cout << ' ' << adjacency_matrix[i][j];
        cout << '\n';
    }
}

C++: #include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define INFTY (1<<30)
#define MAX 100000000

using namespace std;

int main() {
	int n, m[101][101] = {};
	cin >> n;
	for( int i = 1; i <= n; i++) {
		int u, k;
		cin >> u >> k;
		for( int j = 1; j <= k; j++) {
			int v;
			cin >> v;
			m[i][v] = 1;
		}
	}
	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;
	}

    return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> mat(n, std::vector<int>(n, 0));
    
    for (int i = 0; i < n; i++){
        int u, k;
        std::cin >> u >> k;
        while(k--){
            int a;
            std::cin >> a;
            mat[u - 1][a - 1] = 1;
        }
    }
    
    // output
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            std::cout << mat[i][j];
            if (j != n - 1) std::cout << " ";
        }
        std::cout << std::endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int V;
	cin >> V;
	vector <vector <bool>> adj(V, vector <bool> (V, 0));
	rep(V, i) {
		int u, k;
		cin >> u >> k;
		u--;
		rep(k, j) {
			int n;
			cin >> n;
			n--;
			adj[u][n] = 1;
		}
	}
	rep(V, i) rep(V, j) {
		cout << adj[i][j] << ' ';
		if (j == V-1) cout << endl;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}

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


static const int N=100;

int main()
{
    int M[N][N];//0 origin Adjacency matrix
    int n,u,k,v;

    cin >> 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++)
    {
        cin>>u>>k;
        u--; //0 origin
        for(int j = 0; j < k; j++)
        {
            cin>>v;
            v--; //0 origin
            M[u][v]=1;//uとvの間に辺を張る
        }
    }


    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 <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef long long ll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define INF 10000000000 //10^10
#define PI 3.141592

int main(){
    int n;
    cin >> n;
    vector<vint> A(n,vint(n,0));
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v;
            cin >> v;
            A[u-1][v-1]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout << A[i][j];
            if(j<n-1) cout << ' ';
        }
        cout << endl;
    }
}