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 <cstdio>
#include <vector>

int main()
{
    int input_size;
    scanf("%d", &input_size);
    std::vector<std::vector<bool> > neighbor_exists(input_size, std::vector<bool>(input_size, false));
    for(int i = 0; i < neighbor_exists.size(); i++) {
        int id, num_neighbors;
        scanf("%d %d", &id, &num_neighbors);
        for(int j = 0; j < num_neighbors; j++) {
            int neighbor_id;
            scanf("%d", &neighbor_id);
            neighbor_exists[id-1][neighbor_id-1] = true;
        }
    }

    for(int i = 0; i < neighbor_exists.size(); i++) {
        if(neighbor_exists[i][0]) {
            putchar('1');
        } else {
            putchar('0');
        }
        for(int j = 1; j < neighbor_exists[i].size(); j++) {
            putchar(' ');
            if(neighbor_exists[i][j]) {
                putchar('1');
            } else {
                putchar('0');
            }
        }
        putchar('\n');
    }
    return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<vector<int> > mat(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--;
      mat[u][v] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cout << mat[i][j] << (j == n - 1 ? "" : " ");
    }
    cout << "\n";
  }
  return 0;
}

C++: #include <stdio.h>

#define N 100

int main(){

  int u,v,n,k,i,j,A[N][N];

  scanf("%d",&n);

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

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

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

  return 0;
}

C++: #include <iostream>
using namespace std;
int adj[100][100] = {0};
int main()
{
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		int j, k;
		cin >> j >> k;
		j--;
		for (int m=0;m<k;m++) {
			int a;
			cin >> a;
			a--;
			adj[j][a]=1;
		}
	}

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

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

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

C++: #include<bits/stdc++.h>

using namespace std;

void print(vector<vector<int> > a){
    for(int i = 1; i < a.size(); i++){
        for(int j = 1; j < a[0].size(); j++){
            cout << a[i][j];
            if(j + 1 < a[0].size())cout << " ";
        }
        cout << endl;
    }
}

int main(void){
    int n;
    cin >> n;
    vector<vector<int> > a(n+1, vector<int>(n+1));
    for(int i = 1; i <= n; i++){
        int k, l;
        cin >> k >> l;
        for(int j = 1; j <= l; j++){
            int temp;
            cin >> temp;
            a[i][temp] = 1;
        }
    }
    print(a);
    return 0;
}

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

int v[100][100];

signed main()
{
  int n;
  int u, k;

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

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

  return (0);
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int u,k,v;
  int dp[n][n];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++) dp[i][j]=0;
  }

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

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

C++: #include <iostream>
using namespace std;
static const int N=100;
int main(){
    int M[N][N];
    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--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=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>

using namespace std;

int main(){
  int n, u, k, v;
  bool G[100][100] = {0};

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

  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<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int graph[110][110]={0};
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        int v,k,tm;
        cin>>v>>k;
        while(k--)
        {
            cin>>tm;
            graph[v][tm]=1;
        }
    }
    for(int i=1;i<=n;++i)
    {
    for(int j=1;j<=n;++j)
    {
        if(j>1){cout<<" ";}
        cout<<graph[i][j];
    }
    cout<<endl;
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vector<vi> a(n,vi(n));
    rep(i,n){
        int u,k;
        cin>>u>>k;
        u--;
        rep(j,k){
            int v;
            cin>>v;
            v--;
            a[u][v]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout<<a[i][j]<<(j==n-1?"\n":" ");
        }
    }
}