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 <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> V(100, vector<int>(100, 0));
	for (int i = 0; i < n; i++){
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			V.at(u - 1).at(v - 1) = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << V.at(i).at(j);
			if (j == n - 1) {
				cout << endl;
			}
			else
				cout << " ";
		}
	}
}

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

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

C++: #include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define MAX 100000

int main(){
  int n;
  cin >>n;
  int A[n+2][n+2]={0};
  int t,k,l;
  for(int i=1;i<=n;i++){
    cin >> t >> k;
    for(int j=1;j<=k;j++){
      cin >> l;
      A[i][l]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(i) cout << " ";
      cout << A[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

int x[20000][20000],n,q,r,b;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> q >> r;
		for (int j = 0; j < r; j++) {
			cin >> b;
			x[i][b] == true;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) { cout << ' '; }
			cout << x[i][j+1];
		}
		cout << endl;
	}
	return 0;
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);

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

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


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

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

int g[200][200];

int main() {
    int n; cin >> n;
    rep(i, n){
        int x; cin >> x;
        int y; cin >> y;
        rep(j, y){
            int k; cin >> k;
            g[i+1][k] = 1;
        }
    }

    rep(i, n){
        rep(j, n){
            cout << g[i+1][j+1];
            if(j == n-1){
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

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

C++: #include<cstdio>
const short N_MAX = 105;
bool matrix[N_MAX][N_MAX];
int main(){
	int n;
	scanf("%d", &n);
	for(char i=0; i<n;i++){
		int degree, index;
		scanf("%u%u", &index, &degree);
		for(char j=0; j<degree; j++){
			int temp;
			scanf("%d", &temp);
			matrix[index-1][temp-1] = true;
		}
	}
	for(char r=0; r<n; r++){
		for(char c=0;c<n;c++){
			if(c!=0) printf(" ");
			printf("%d", matrix[r][c]);
		}
		printf("\n");
	}
	return 0;
}

C++: #include<cstdio>
#include<algorithm>

int main()

{

  int k,v,n,i,j,m=0;

  scanf("%d",&n);

  int Adj[n][n];

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

  }
    
  }

  
  

  for(i=0; i<n; i++)
    {
      scanf("%d",&m);
      scanf("%d",&k);
      for(j=0; j<k; j++)
	{
	  scanf("%d",&v);
	  Adj[i][v-1]=1;
	}
      
    }
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      printf("%d",Adj[i][j]);
      if(j!=n-1) printf(" ");
	

  }
    printf("\n");
  }
  
  
}

C++: 
#include <iostream>
using namespace std;
int main()
{
	int total,TotalOfConnectedNode,node,connectednode;
	int AM[101][101];
	for (int i = 0; i < 101; i++)
		for (int j = 0; j < 101; j++)
			AM[i][j] = 0;

	
	cin >> total;
	for (int i = 0; i < total; i++)//有向图
	{
		cin >> node>>TotalOfConnectedNode;
		if (TotalOfConnectedNode == 0) continue;
		for (int i = 0; i < TotalOfConnectedNode; i++)
		{
			cin >> connectednode;
			AM[node][connectednode] = 1;
			//AM[connectednode][node] = 1;无向图

		}
	}
	for (int i = 1; i <= total; i++)
	{		for (int j = 1; j <= total; j++)
			{	
			   if(j>1)
			    cout << " ";
			   cout<< AM[i][j];
			    
			}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#define mop 1000000007

using namespace std;
int m[101][101] = {};

int main() {
    
    int n;
    cin >> n;
    for (int i=0;i<n;i++){
        int p,k;
        cin >> p >> k;
        for (int j=0;j<k;j++){
            int q;
            cin >> q;
            m[i+1][q] = 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;
    }


}

C++: #include <iostream>
using ll = long long;
using namespace std;
/* initialize */

/* main */
int main() {
    int n,u,k, v;
    int A[100][100];
    cin >> 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) {
        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-1; ++j) {
            cout << A[i][j] << " ";
        }
        cout << A[i][n-1] << "\n";
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int g[n][n] = {};
	for(int i = 0; i < n; i++){
		int u,k;
		cin >> u >> k;
		int v;
		for(int j = 0; j < k; j++){
			cin >> v;
			g[u-1][v-1] = 1;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cout << g[i][j];
			if(j != n-1)
				cout << " ";
		}
		cout << endl;
	}
}