Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			fmt.Printf(" %d", Adj[i][j])
			if j == n-1 {
				fmt.Println()
			}
		}
	}
}

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>



using namespace std;

static const int N = 100;
int A[N+1][N+1];

int main(){
    
    for (int i=0;i<=N;i++){
        A[i][0] = 0;
    }
    for (int j = 0;j<=N;j++){
        A[0][j] = 0;
    }
    int n;
    cin >> n;
    for (int i=1;i<=n;i++){
        int p,k;
        cin >> p >> k;
        for (int j=0;j<k;j++){
            int a;
            cin >> a;
            A[i][a] = 1;
           
        }
    }

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

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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int n;
  cin >> n;
  vector<vector<int> > G;
  G.resize(n);
  for(int i = 0; i < n; i++){
    int u, k;
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      int tmp;
      cin >> tmp;
      G[i].push_back(tmp);
    }
  }
  for(int i = 0; i < n; i++){
    int k = 0;
    for(int j = 0; j < n; j++){
      if(G[i].size() != 0){
        if(G[i][k] == j + 1){
          cout << 1;
          k++;
        }else cout << 0;
      }else cout << 0;
      if(j != n - 1)cout << " ";
    }

      cout << endl;
      k = 0;
  }
}

C++: #define REP(i,n) for (int i=0;i<(n);i++)
#include <iostream>
using namespace std;
int main(){
        int n,u,k,v;
        cin >> n;
        int g[n][n];
        REP(i,n){
                REP(j,n){
                        g[i][j] = 0;
                }
        }
        REP(i,n){
                cin >> u >> k;
                REP(j,k){
                        cin >> v;
                        g[v-1][u-1] = 1;
                }
        }
        REP(i,n){
                REP(j,n){
                        cout << (j?" ":"") << g[j][i];
                }
                cout << endl;
        }
}

C++: #include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define INFTY 2000000001
#define MAX 101

int n = 0;
int adl[MAX][MAX], deg[MAX];
int adm[MAX][MAX];

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      adm[i][j] = 0;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int num;
    scanf("%d", &num);
    num--;
    scanf("%d", &deg[num]);
    for ( int j = 0; j < deg[num]; j++) {
      scanf("%d", &adl[num][j]);
      adl[num][j]--;
      adm[num][adl[num][j]] = 1;
    }
  }

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

  return 0;
}

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

static const int MAX = 100;

int main(){
    int n;
    scanf("%d",&n);
    int u,k,adj[MAX][MAX],tmp;
    memset(adj,0,sizeof(adj));
    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(int m=0;m<k;m++){
            scanf("%d",&tmp);
            adj[u-1][tmp-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int m=0;m<n;m++){
            if(m) printf(" ");
            printf("%d",adj[i][m]);
            if(m==3) printf("\n");
        }
    }

    return 0;
}

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

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

  vector<vector<int>> g(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      g[i][j] = 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--;
      g[u][a] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j != 0) cout << " ";
      cout << g[i][j];
    }
    cout << endl;
  }
}

C++: #include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int N_MAX = 101;


int main(void){

	int N; cin >> N;
	int adj[N_MAX][N_MAX];
	REP(i,N) REP(j,N) adj[i][j] = 0;

	REP(i,N){
		int u,k; cin >> u >> k; u--;
		REP(j,k){
			int v; cin >> v; v--;
			adj[u][v] = 1;
		}
	}

	REP(i,N){
		int j;
		for(j=0;j<N-1;++j){
			cout << adj[i][j] << ' ';
		}
		cout << adj[i][j] << endl;
	}


	return 0;

}

C++: #include <stdio.h>
#define N 101

int main() {

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

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    while(k>0){
      scanf("%d",&l);
      a[u][l] = 1;
      k--;
    }
  }

  for(i=1;i<=n;i++) {
    for(j=1;j<=n;j++){
      printf(" %d",a[i][j]);
    }
    printf("\n");
  }

  
  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; j++)
	{
	  if (ln[i][j] != 0 && m[j][i]==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] << " ";
	}
      cout << endl;
    }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a[100][100];
	int n,u,k,v;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			a[i][j]=0;
		}
	}
	for(int j=0;j<n;j++){
		cin>>u>>k;
		for(int i=0;i<k;i++){
			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;
	}
	return 0;
}

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

static const int MAX = 100;

int main(){
    int n;
    scanf("%d",&n);
    int u,k,adj[MAX][MAX],tmp;
    memset(adj,0,sizeof(adj));
    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(int m=0;m<k;m++){
            scanf("%d",&tmp);
            adj[u-1][tmp-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int m=0;m<n;m++){
            if(m) printf(" ");
            printf("%d",adj[i][m]);
            if(m==3) printf("\n");
        }
    }

    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool ans[101][101];
int main(){
  int n,u,k,v;
  cin>>n;
  for(int j=0;j<n;j++){
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v;
      ans[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
      cout<<ans[i][j];
      if(j==n)cout<<endl;
      else cout<<" ";
    }
  return 0;
}