Go: package main

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	n := nextInt()
	v := make([][]int, n)
	for i := 0; i < n; i++ {
		u := nextInt()
		k := nextInt()
		for j := 0; j < k; j++ {
			v[u-1] = append(v[u-1], nextInt())
		}
	}

	for _, vvs := range v {
		for j := 1; j <= n; j++ {
			if j > 1 {
				fmt.Fprint(w, " ")
			}
			p := sort.SearchInts(vvs, j)
			if p < len(vvs) && vvs[p] == j {
				fmt.Fprint(w, 1)
			} else {
				fmt.Fprint(w, 0)
			}
		}
		fmt.Fprintln(w)
	}

	w.Flush()
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

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

int main(){
    int n, val, link, linknum;
    cin >> n;
    int Graphlinked[n][n];
    for(int i=0; i<n; i++){
        for(int k=0; k<n; k++){
            Graphlinked[i][k] = 0;
        }
        cin >> val >> linknum;
        for(int j=0; j<linknum; j++){
            cin >> link;
            Graphlinked[i][link - 1] = 1;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j) cout << " ";
            cout << Graphlinked[i][j];
        }
        cout << endl;
    }
}

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

int main(){
	int n,a,b=-1,j=0;
	char input[110];
	string scan;
	int line[110]={0};
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int k=1;k<=n;k++)line[k]=0;
		strcpy(input,"");		
		b=-1; j=0;
		while(1){
			b--;
			if(b==0)break;
			cin>>a;
			if(b>0)line[a]=1;
			
			if(j==1)b=a+1;
			j++;
		}
		for(int k=1;k<=n;k++)cout<<line[k]<<" ";
		cout<<endl;
	}
	
	return 0;
}

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

const static int N = 100;

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

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

  return 0;    
}

C++: /** ???????????????, ??¢??°?????¨??? **/
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

// ?????\?????????
// ?????°:?????????????´???°, ??????
// ???????????°????????§?????????????????´?£????????????´??????
// Down: ??????, Up: ??????
void insertionSortDown(int *a, int N){
    for(int i=1; i<N; i++){
        //???????????????,???????????????????´?????????????????????¨??????
        int v = a[i];
        int j = i - 1;

        //????????????????????¨?????¨??????????????????. ?????´??????????????????.
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;

        /**
        cout << to_string(i) << "??????" << endl;
        for(int k=0; k<N; k++){
            cout << a[k] << endl;
        }
         **/
    }
}

void insertionSortUp(int *a, int N){
}

// ??????????????????
// ???????????´?£????????????´??????. ?????????????????°return?????????int???????????´??????
void bubbleSortUp(int *a, int N){
    int sw = 0;
    int flag = 1;

    while(flag == 1){
        flag = 0;

        for(int j=N-1; j>=sw; j--){
            if(a[j-1] > a[j]){
                swap(a[j-1], a[j]);
                flag = 1;
            }
        }
        sw++;
        //???????????´???????????????????????¨????????¨???????????£??????????????§.
    }
}

void selectionSortUp(int *a, int N){
    for(int i=0; i<N-1; i++){
        int minj = i;

        for(int j=i; j<N; j++){
            if(a[minj] > a[j]){
                minj = j;
            }
        }
        swap(a[minj], a[i]);
        //???????????´??§??????????????°??????????????????????????????,???????°????????????????????´???¨??????????????????
    }
}

// ?????¢??¢?´¢ O(nq)
// ??????, ?????????????´???°, ?????????????????????
bool linearSearch(int *a, int n,int key){
    int i = 0;
    a[n] = key; //??????????????????????????????

    while(a[i] != key) i++;

    //????´?????????????????????§??????????????°true?????????
    return i != n;
}


#define V_MAX 100

vector<int> V[V_MAX];
int M[V_MAX][V_MAX];

int main(){

    int n;
    cin >> n;
    int from, degree, tmp;

    for(int i=1; i<=n; i++){
        cin >> from >> degree;
        for(int j=0; j<degree; j++){
            cin >> tmp;
            V[from].pb(tmp);
        }
    }

    /**
     * ?¢??????¨
    for(int i=1; i<=n; i++){

        cout << i << "?????? ";

        vector<int>::iterator ite;
        for(ite = V[i].begin(); ite != V[i].end(); ite++) cout << (*ite) << " ";

        cout << endl;
    }
     **/

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            vector<int>::iterator ite;
            for(ite = V[i].begin(); ite != V[i].end(); ite++){
                if(*ite == j) M[i][j] = 1;
            }
        }
    }

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

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

#define MAX 100

int A[MAX][MAX];


int main(){
    int n, u, k, v;
    cin >> n;

    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < MAX; j++){
            A[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オリジンに変換
            A[u][v] = 1;
        }
    }

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

    return 0;
}

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

using namespace std;

int main(void){

  int graph[100][100];
  fill( graph , graph + 100 , 0 );

  int n;
  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    int u, k;
    cin >> u >> k;
    u--;
    while( k-- ){
      int v;
      cin >> v;
      v--;
      graph[u][v] = 1;
    }
  }
  for( int i = 0 ; i < n ; i++ ){
    for( int j = 0 ; j < n ; j++ ){
      if( j == n - 1 ) cout << graph[i][j] << endl;
      else cout << graph[i][j] << " ";
    }
  }
  return 0;
}