Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

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

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

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

	int a[100][100] = {0};

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

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

	return 0;
}

C++: #include<stdio.h>
#define MAX 101

int main() {
    int n;
    int G[MAX][MAX];

    scanf("%d", &n);
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            G[i][j] = 0;
        }
    }

    int k, u, m;
    for (int i=1; i<=n; i++) {
        scanf("%d", &u);
        scanf("%d", &m);
        for (int j=1; j<=m; j++) {
            scanf("%d", &k);
            G[u][k] = 1;
        }
    }

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (j==1) printf("%d", G[i][j]);
            else printf(" %d", G[i][j]);
        }
        printf("\n");
    }

    return 0;
}

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

class branch{
  int to;
  branch(int to){
    this->to = to;
  }
};

int main(){
  int n; cin >> n;
  vector<branch> graph[n+1];
  int g[n+1][n+1];
  memset(g, 0, sizeof(g));

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

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

  return 0;
}

C++: #include <iostream>
#include <vector>
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 u, k, v;
        cin >> u;
        for (int j=0; j<k; j++) {
            cin >> v;
            a[u-1][v-1] = 1;
        }
    }
    
    for (int i=0; i<n; i++) {
        for (int j=0; j<n-1; j++) {
            cout << a[i][j] << " ";
        }
        cout << a[i][n-1] << endl;
    }
}

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

using namespace std;

class Graph{
private:
 vector< vector<unsigned long> > graph;
public:

 Graph(unsigned long num) : graph(num+1, vector<unsigned long>(num+1, 0)){
  for(unsigned long row_i = 0; row_i < num; ++row_i){
   unsigned long nodeNum = 0; cin >> nodeNum;
   unsigned long nodeMax = 0; cin >> nodeMax;

   for(unsigned long node_i = 0; node_i < nodeMax; ++node_i){
    unsigned long adjectNode = 0; cin >> adjectNode;

    graph[nodeNum][adjectNode] = 1;
   }
  }

 };

 void display(){
  for(unsigned long i = 1, num = graph.size(); i < num; ++i){
   for(unsigned long j = 1; j < num; ++j){
    if(j != 1) cout << " ";
    cout << graph[i][j];
   }
   cout << endl;
  }
 };

protected:
};

int main(){

 unsigned long num = 0; cin >> num;

 Graph g(num);
 g.display();

 return 0;
};

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

int main(void) {
    int  n;
    cin>>n;
    int g[101][101];
    for (int i = 0; i < n;i++) {
        for (int j = 0; j<n;j++) {
            g[i][j] = 0;
        }
    }
    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++) {
            if(j) cout<<" ";
            cout<<g[i][j];
        }
        cout<<"\n";
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<vector<int> > v(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int x; cin >> x;
      v[u - 1][x - 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;
}

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

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;


int G[100][100];
int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int k,n,u;
    cin >> n;
    for(int i = 0; i < n ; i++){
        cin >> u;
        cin >> k;
        for(int i2 = 0; i2 < k ; i2++){
            int j;
            cin >> j;
            G[i][j-1] = 1;
        }
    }

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

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

int main()
{
    int n,k;
    int A[100][100]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int x;
            cin>>x;
            A[i][x]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==n-1&&j==n-1)
                cout<<A[i][j];
            else
                cout<<A[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

C++: #if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N;
int GM[110][110];
vector<int> GL[110];

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      GM[i][j] = 0;
  }
  int u, k;
  for (int i = 1; i <= N; i++) {
    cin >> u >> k;
    int t;
    for (int j = 0; j < k; j++) {
      cin >> t;
      GM[i][t] = 1;
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      cout << GM[i][j] << (j == N ? '\n' : ' ');
  }
}

C++: #include<stdio.h>
#define N 100

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

    scanf("%d",&n);

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

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

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

int main(){
    int n,u,k,v;
    int m[MAX][MAX];
    
    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!=0)cout<<" ";
            cout << m[i][j];
        }cout<<endl;
    }
    
    return 0;
    
}