Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

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;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1
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--;//0オリジンに変換
    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];  
         if(j == n-1) cout << endl;
      }
}
}

C++: #include <iostream>

int main(){
    int vertex;
    std::cin.tie( 0 );
    std::cin >> vertex;

    bool** adjMatrix = new bool*[vertex];
    for( int i = 0; i < vertex; ++i ){
        adjMatrix[i] = new bool[vertex];
    }

    for( int i = 0; i < vertex; ++i ){
        for( int j = 0; j < vertex; ++j ){
            adjMatrix[i][j] = false;
        }
    }

    int tag;
    int degree;
    int tmp;
    for( int i = 0; i < vertex; ++i ){
        std::cin >> tag >> degree;
        while( degree-- > 0 ){
            std::cin >> tmp;
            adjMatrix[tag-1][tmp-1] = true;
        }
    }

    for( int i = 0; i < vertex; ++i ){
        for( int j = 0; j < vertex; ++j ){
            std::cout << static_cast<int>( adjMatrix[i][j] ) << ( ( j < vertex-1 )? " " : "\n" );
        }
    }

    delete[] adjMatrix;
}

C++: #include<cstdio>
#include<array>
using namespace std;
const int MAX_V = 100;
array<array<int,MAX_V>,MAX_V> ary{0};
int main(){
  int n;scanf("%d",&n);
  for(int i=0;i<n;i++){
    int u;scanf("%d",&u);
    int k;scanf("%d",&k);
    for(int j=0;j<k;j++){
      int v;scanf("%d",&v);
      ary[v-1][u-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      printf(j==n-1?"%d\n":"%d ",ary[j][i]);
    }
  }
}