Go: package main

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

func main() {
	var n int
	fmt.Scanf("%d", &n)

	adj := make([][]string, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]string, n)
		for j := 0; j < n; j++ {
			adj[i][j] = "0"
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		sc.Scan()
		adjList := strings.Split(sc.Text(), " ")
		outDegree, _ := strconv.Atoi(adjList[1])

		if outDegree > 0 {
			for k := 0; k < outDegree; k++ {
				j, _ := strconv.Atoi(adjList[k+2])
				adj[i][j-1] = "1"
			}
		}
	}

	for i := 0; i < len(adj); i++ {
		fmt.Println(strings.Join(adj[i], " "))
	}

}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include<algorithm>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 
using namespace std;

long long mod = 1000000007;



int main()
{
	int N,M[100][100];
	cin >> N;

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			M[i][j] = 0;
		}
	}

	int u, k, v;
	for (int i = 0; i < N; i++) {
		cin >> u >> k;
		u--;
		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 == 0)
				cout << M[i][j];
			else
				cout << " " << M[i][j];
		}
		cout << endl;
	}


	


	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MAX=105;
int M[MAX][MAX];
int main(){
	int n,u,k;
	cin>>n;
	memset(M,0,sizeof(M));
	for(int i=0;i<n;i++){
		cin>>u>>k;
		int v;
		for(int j=0;j<k;j++){
			cin>>v;
			M[u][v]=1;
		}
	}		
	for(int i=1;i<=n;i++){
		int first=1;
			for(int j=1;j<=n;j++){
				if(first)first=0;else putchar(' ');
				cout<<M[i][j];
			}
			cout<<endl;
		}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;
//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;
//Unweighted graph (adjacency matrix)
using UnweightedGraph = vector<vector<int>>;
//distance matrix
template <typename T>
using Matrix = vector<vector<T>>;

int main()
{
    int N;
    cin >> N;
    UnweightedGraph G = vector<vector<int>>(N, vector<int>(N, 0));
    for (int i = 0; i < N; i++)
    {
        int a, c;
        cin >> a >> c;
        a--;
        for (int j = 0; j < c; j++)
        {
            int b;
            cin >> b;
            b--;
            G[a][b]++;
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << G[i][j] << (j == N - 1 ? "\n" : " ");
        }
    }
}

C++: #include<stdio.h>

int main(){
  int i,j,n,k,c,b;

  int a[124][124]={{}};

  scanf("%d",&n);
  for(i=0;i<n;i++){

    scanf("%d %d",&c,&b);
    for(j=0;j<b;j++){
      scanf("%d",&k);
      a[c-1][k-1]=1;

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

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

void fnInput(vector<vector<int>> &rvvnAdjcy)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvvnAdjcy.resize(nMaxSiz + 1, vector<int>(nMaxSiz + 1, 0));
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nx, nSecSiz;
    cin >> nx >> nSecSiz;
    for (int j = 0; j < nSecSiz; j++)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
}

void fnResult(const vector<vector<int>> &cnrvvnAdjcy)
{
  for (int i = 1; i < cnrvvnAdjcy.size(); i++)
  {
    for (int j = 1; j < cnrvvnAdjcy[i].size(); j++)
      cout << cnrvvnAdjcy[i][j] << " ";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;

  fnInput(vvnAdjcy);
  fnResult(vvnAdjcy);

  return 0;
}

C++: 
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

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

}

C++: #include<stdio.h>
#define N 100
int main(){
  int a[N][N],v[N];
  int n,i,j,u,k;


  scanf("%d",&n);

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

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

  
  return 0;
}

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

using namespace std;

int main() {
	int n,row,size,tmp;
	cin >> n;
	int** mat = new int* [n];
	for (int i = 0;i < n;i++) {
		cin >> row >> size;
		mat[row - 1] = new int[n];
		for (int j = 0;j < n;j++) {
			mat[row - 1][j] = 0;
		}
		for (int j = 0;j < size;j++) {
			cin >> tmp;
			mat[row - 1][tmp - 1] = 1;
		}
	}
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n-1;j++) {
			cout << mat[i][j] << " ";
		}
		cout << mat[i][n - 1] << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int lst[n+1][n+1];
    REPP(i,1,n+1) REPP(l,1,n+1) lst[i][l] = 0;

    int idx,op,tmp;
    for(int i = 0; i < n;i++){
        cin >> idx >> op;
        for(int l = 0; l < op;l++){
            cin >> tmp;
            lst[idx][tmp] = 1;
        }
    }

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


    

    return 0;
}

C++: #include <stdio.h>


int main() {

   int m[100][100];
   int n, s, t, u, i,  j;

   scanf("%d", &n);
   for ( i = 0; i < n; i++) {
      for ( j = 0; j < n; j++) {
         m[i][j] = 0;
      }
   }

   for ( i = 0; i < n; i++) {
      scanf("%d", &s);
      scanf("%d", &t);
      for ( j = 0; j < t; j++) {
         scanf("%d", &u);
         m[s - 1][u - 1] = 1;
       }
   }
   for ( i = 0; i < n; i++) {
      for ( j = 0; j < n; j++) {
      printf("%d", m[i][j]);
      if ( j < n - 1) {
         printf(" ");
            }
         }
      printf("?\n");
      }
      return 0;
   }