Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <cstring>
using namespace std;

int n;


int main(void){

	cin >> n;
	int suji[n];
	int	num[n];
	int adj[n][n];
	int ans[n][n];

	

	for(int i = 0; i < n; i++){
		
		cin >> suji[i] >> num[i];

		
		for(int j = 0; j < num[i]; j++){
			cin >> adj[i][j];
			adj[i][j] -= 1;
		}
	}

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

	for(int i = 0; i < n; i++){
		for(int j = 0; j < num[i]; j++){
			ans[i][adj[i][j]] = 1;
		}
	}

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



	
    return 0;
}

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

int main(){
    int M[N][N]; // 0?????????????????£??\??????
    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?????????????????????
        for( int j = 0; j < k; j++){
            cin >> v;
            v--; // 0?????????????????????
            M[u][v]  = 1; //u??¨v?????????????????????
        }
    }
    
    for ( int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (j) cout << " "; // j = 0??\???????????????????????\?????§?????????????????\??????
            cout << M[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 < n; 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(void) {
	int N = 0;
	cin >> N;

	int* *A = new int*[N];
	for (int i = 0; i < N; i++)
		A[i] = new int[N];

	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++) {
		int u, v,w;
		cin >> u;
		u--;

		cin >> v;
		for (int j = 0; j < v; j++) {
			cin >> w;
			w--;
			A[u][w] = 1;
		}
	}

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

C++: #include <iostream>

int main()
{
	int n; std::cin >> n;
	
	int** A = new int*[n];
	for (int i=0; i<n; i++) A[i] = new int[n];
	
	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++) {
		int x;
		int deg;
		std::cin >> x >> deg;
		for (int d=0; d<deg; d++) {
			int y;
			std::cin >> y;
			A[x-1][y-1]++;
		}
	}
	
	for (int i=0; i<n; i++) {
		std::cout << A[i][0];
		for (int j=1; j<n; j++) {
			std::cout << " " << A[i][j];
		}
		std::cout << std::endl;
	}
	
	return 0;
}

C++: #include<iostream>

int main() {
	int node_num, adj[100][100];

	std::cin >> node_num;

	for (int i = 0; i < node_num; i++) {
		int node, num;
		std::cin >> node >> num;
		for (int j = 0; j < num; j++) {
			int n;
			std::cin >> n;
			adj[i][n - 1] = 1;
		}
	}

	for (int i = 0; i < node_num; i++) {
		for (int j = 0; j < node_num; j++) {
			std::cout << adj[i][j] << (j != node_num - 1 ? " ":"");
		}
		std::cout << std::endl;
	}
}

C++: #include <cstdio>
#include <iostream>
#include <queue>
static const int N = 110;

using namespace std;

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

    for(int i=0; i<n;i++){
        int u,k;
        scanf("%d",&u);
        scanf("%d",&k);

        for(int j=0; j<k; j++){
            int l;
            scanf("%d",&l);
            M[u][l] = 1;
        }
    }

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

    return 0;
}

C++: //16D8103012G 三品海渡
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 2; j < n+1; j++)
	{
	  if (ln[i][j] != 0 )
	    {
	      m[i][ln[i][j]-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 << " ";
	    }
	}
      cout << endl;
    }
  return 0;
}

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

int n;
int M[101][101];
int main() {
    cin >> n;

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

    for (int l = 1; l <= n; ++l) {
        for (int i = 1; i <= n; ++i) {
            if(i != 1) cout << " ";
            cout << M[l][i] ;
        }
        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 < k; 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 < k; j++) {
			if ( j ) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
	int n, k, u, v;
	cin >> n;
	// N * N matrix filled with 0
	vector< vector<int> > mat(n, vector<int>(n, 0));

	for(int i=0; i<n; i++){
		cin >> u >> k;
		// adjust 0 origen
		u--;
		for(int j=0; j<k; j++){
			cin >> v;
			//cout << "vertex: " << v << '\n';
			// adjust 0 origen
			v--;
			mat[u][v] += 1;
		}
		//cout << '\n';
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(j==0) printf("%d", mat[i][j]);
			else printf(" %d", mat[i][j]);
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n,x,y,z;
    cin>>n;
    int a[n+1][n+1];
    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++){
        cin>>x>>y;
        if(y!=0){
            for(int j=0;j<y;j++){
                cin>>z;
                a[x][z]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<a[i][n]<<endl;
    }
    return 0;
}