Go: package main

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	n := nextInt()
	v := make([][]int, n)
	for i := 0; i < n; i++ {
		u := nextInt()
		k := nextInt()
		for j := 0; j < k; j++ {
			v[u-1] = append(v[u-1], nextInt())
		}
	}

	for _, vvs := range v {
		for j := 1; j <= n; j++ {
			if j > 1 {
				fmt.Fprint(w, " ")
			}
			p := sort.SearchInts(vvs, j)
			if p < len(vvs) && vvs[p] == j {
				fmt.Fprint(w, 1)
			} else {
				fmt.Fprint(w, 0)
			}
		}
		fmt.Fprintln(w)
	}

	w.Flush()
}

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




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; cin >> u >> k;
            if(k==0) continue;
            for(int j=0;j<k;j++){
                  int v; cin >> v;
                  a[u-1][v-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<<" ";
                  }
                  
            }
            cout << endl;

      }
}

C++: #include <iostream>

using namespace std;


int main() {

	int a[100][100];

	int n;

	cin >> n;

	int u, k, v;

	for ( int i = 0; i < n; i++ ) {

		for ( int x = 0; x < 100; x++ )

			for ( int y = 0; y < 100; y++ )

				a[x][y] = 0;

		cin >> u >> k;

		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; j++ ) {

			cout << a[i][j];

			if ( j != n - 1 ) cout << " ";

		}

		cout << endl;

	}

}

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

using namespace std;

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

int main() {
    int N;
    cin >> N;
    auto mat = Vec<int>(N, N, 0);
    for (int i = 0; i < N; ++i) {
        int v, k;
        cin >> v >> k;
        --v;
        for (int j = 0; j < k; ++j) {
            int sv;
            cin >> sv;
            mat[v][--sv] = 1;
        }
    }

    for (const auto& v : mat) {
        for (int i = 0; i < v.size(); ++i) {
            cout << v[i] << " \n"[i == v.size() - 1];
        }
    }
    return 0;
}

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

int main() {
    int A[101][101];

    int n;
    cin >> n;

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

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

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

class TVertex
{
    int FValue;
    std::vector<TVertex*> FList;
public:
    TVertex(int Value)
     : FValue(Value)
    {}
    void AddPath(TVertex* Vertex)
    {
        FList.push_back(Vertex);
    }
    void PrintMatrix(std::ostream& out, int MaxIndex)const
    {
        std::vector<TVertex*>::const_iterator It = FList.begin();
        for(int i = 1; i < MaxIndex; ++i){
            if(i > 1) out << " ";
            if(It != FList.end() && (*It)->FValue == i){
                out << 1;
                ++It;
            }else{
                out << 0;
            }
        }
        out << std::endl;
    }
};
class TGraph
{
    std::vector<TVertex*> FTable;
    void Init(int n)
    {
        assert(n > 0);
        FTable.resize(n);
        for(int i = 0; i < n; ++i){
            FTable[i] = new TVertex(i);
        }
    }
public:
    TGraph(int n)
    {
        Init(n+1);
    }
    
    void SetupVertex(std::istream& in)
    {
        int Index;
        in >> Index;
        assert(Index >= 1);
        assert(Index <= FTable.size());
        int k;
        in >> k;
        for(int i = 0; i < k; ++i){
            int v;
            in >> v;
            FTable[Index]->AddPath(FTable[v]);
        }
    }
    void PrintMatrix(std::ostream& out)
    {
        for(int i = 1; i < FTable.size(); ++i){
            FTable[i]->PrintMatrix(out, FTable.size());
        }
    }
};

int main()
{
    int n;
    std::cin >> n;
    TGraph Graph(n);
    for(int i = 0; i < n; ++i){
        Graph.SetupVertex(std::cin);
    }
    Graph.PrintMatrix(std::cout);
    return 0;
    
}

C++: int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j] << " ";
        }
        cout << endl;
    }
}

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

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

    }
    for(int k=0; k<n-1; k++){
      cout << a[i][k] << ' ';
    }
    cout << a[i][n-1] <<endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int T[100][100];

void init(){
	for (int i = 0; i < 100; ++i)
	{
		for (int j = 0; j < 100; ++j)
		{
			T[i][j] = 0;
		}
	}
}

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

int main(){
	int n;
	cin >> n;
	init();
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			T[u-1][v-1] = 1;	
		}
	}
	DispTable(n);
	return 0;
}

C++: #include <iostream>

using namespace std;

#define N_MAX 100

int main()
{
    int n, i, j, u, k, v;
    int Adj[N_MAX][N_MAX] = {};

    cin >> n;

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

    for (i = 0; i < n; i++) {
        for (j = 0; j < n ; j++) {
            if (j == n - 1)
                cout << Adj[i][j] << endl;
            else
                cout << Adj[i][j] << ' ';
            /*
            cout << Adj[i][j] << ' ';
            if (j == n - 1)
                cout << endl;
            */
        }
    }

    return 0;
}