Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.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;
}