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>
using namespace std;
static const int N = 120;

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;
  bool info[100][100] = {{}};
  cin >> N;
  for(int i = 0; i < N; i++){
    int u, k;
    cin >> u >> k;
    while(k--){
      int v;
      cin >> v;
      info[u - 1][v - 1] = true;
    }
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cout << info[i][j] << (j + 1 == N ? '\n' : ' ');
    }
  }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int M[101][101];
int main(){
  int n,u,k,v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  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 ) cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>

using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j] << " ";
    }
    cout << endl;
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}

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

int graph[MAX_N+1][MAX_N+1];

int main() {
  int n;
  int u,k,v;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> u >> k;
    for(int j=0;j<k;j++) {
      cin >> v;
      if(graph[u][v] == 0)
        graph[u][v] = 1;
    }
  }

  for(int i=1;i<=n;i++) {
    for(int j=1;j<=n;j++) {
      cout << graph[i][j] << (j==n ? "\n" : " ");
    }
  }
}

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

int main()
{
	int M[N][N];	// 0 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 << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

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

using namespace std;


struct Edge{ //??°????????????
public:
    int src, dst;
    int weight;
    Edge(int a,int b):src(a),dst(b),weight(1){} //?????????????????????
    void setWeight(double x){
        weight = x;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<int> Array;
typedef vector<Array> Matrix;


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


int main(){ //??°???????????£??\??????????????£??\?????????????????????????????°??????
    
    int n,k,v,w;
    
    cin >> n; //??°????????????????????\???
    
    Matrix M(n,Array(n,0)); //??£??\??????????????????
    
    for (int i=0; i<n; i++) { //??????????¬???°?????????????????\??? ???????????\??????????????£??\??????????????£??\?????????????´?
        cin >> w >> k;
        for (int j=0; j<k; j++) {
            cin >> v;
            M[w-1][v-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 main(){
	int adj[100][100] = {};
	int n;
	cin >> n;
	int a,b,c;
	for (int i=0; i<n;i++){
	cin >> a >> b;
	//adj[num1-1]?????\??????
	
	for (int j=0;j<b;j++){
	cin >> c;
	adj[a-1][c-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<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int e[n][n];
  memset(e,0,sizeof(e));
  for(int i=0,u,k;i<n;i++){
    cin>>u>>k;
    for(int j=0,v;j<k;j++){
      cin>>v;
      e[u-1][v-1]=1;
    }
  }
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cout<<e[i][j]<<" \n"[j==n-1];
  return 0;
}

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

//??£??\?????????????¬??????????????¨???¶???	arrey[i][j] i??????j???????????????
//??£??\?????????????????????????????????????????????,?????????????¨???¶
//ALDS1_11-A
int n,u,k,a;
int map[101][101];
int main(){
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			map[i][j]=0;
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u;
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>a;
			map[u][a]=1;
		}
	}
	for(int i=1;i<n+1;i++){
		for(int j=1;j<n+1;j++){
			cout<<map[i][j];
			if(j==n)cout<<endl;
		}
	}
	return 0;
}

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

int v,A[100][100],u,k,w;


int main(){
    cin >> v ;
    for (int i=0; i<v; ++i){
        cin >> u >> k;
        for(int j=0; j<k; ++j){
            cin >> w;
            A[u-1][w-1] = 1;
        }
    }
    for (int i=0; i<v; ++i){
        for (int j=0; j<v; ++j){
            cout << A[i][j];
            cout << " ";
        }
        cout << endl ;
    }
}