Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

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

int main() {
  int n;
  cin >> n;
  int G[n][n];
  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 vi, out_v_num;
    cin >> vi;
    cin >> out_v_num;
    for (int j = 0; j < out_v_num; j++) {
      int out_vi;
      cin >> out_vi;
      G[vi-1][out_vi-1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }
}

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

int main(){
	int adj[100][100] = {};
	int n;
	cin >> n;
	int num1,num2,num3;
	for (int i=0; i<n;i++){
	cin >> num1 >> num2;
	//adj[num1-1]?????\??????
	for (int j=0;j<num2;num2++){
	cin >> num3;
	adj[num1-1][num3-1] = 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>
#include<algorithm>
#define MAX 101
using namespace std;
int main(void){
    int n,A[MAX][MAX]={0};
    cin >> n;
    for(int i=0;i<n;i++){
        int id,adj;
        cin >> id >> adj;
        for(int j=0;j<adj;j++){
            int k;
            cin >> k;
            A[id-1][k-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j>0){
                cout << ' ';
            }
            cout << A[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;


int main()
{
	int n;
	vector<vector<int>> a;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		a[i].resize(n);
	}
	for (int i = 0; i < n; i++) {
		int temp, k;
		cin >> temp >> k;
		for (int j = 0; j < k; j++) {
			int temp2;
			cin >> temp2;
			a[temp - 1][temp2 - 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 << endl;
			}
			else {
				cout << " ";
			}
		}
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, k[102], v[101][102] = {0}, i, j, l, a;

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

  for (i = 0; i < n; i++) {
    for (j = 0; j < n + 1; j++) {
      if (k[i] == 0) {
        for (l = v[i][j - 1]; l < n - 1; l++) {
          cout << "0 ";
        }
        cout << "0\n";
        break;
      }
      else {
        if (v[i][j] != 0) {
          k[i]--;
          for (l = v[i][j - 1]; l < v[i][j] - 1; l++) {
            cout << "0 ";
          }
          if (v[i][j] == n) {
            cout << "1\n";
            break;
          }
          else {
            cout << "1 ";
          }
        }
      }
    }
  }

  return 0;
}

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

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

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

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

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

int main(){

  int u,k,i,j,v,n;
  int a[N][N];
 
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }
  
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      if(a[i][j]==NULL)a[i][j]=0;
    }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][n]);
  }

  return 0;

}

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

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

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                if(vec[i][k]==j) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }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,m,l,i,j,p;
	cin >> n;
	int f[101][101];
	for ( i = 0; i < n; i++){
		cin >> m;
		cin >> p;
		for ( j = 0; j < p; j++){
			cin >> l;
			f[m-1][l-1] = 1;
		}
	}
	for ( i = 0; i < n; i++){
		for ( j = 0; j < n-1; j++){
			cout << f[i][j] << " ";
		}
		cout << f[i][n-1] << endl;
	}
}

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

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

    std::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++) {
        std::cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            std::cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

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

    return 0;
}