Go: package main

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

const N = 100

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var M [N][N]int
	for i := 0; i < n; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		u--
		for j := 0; j < k; j++ {
			sc.Scan()
			v, _ := strconv.Atoi(sc.Text())
			v--
			M[u][v] = 1
		}
	}

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				out.WriteString(" ")
			}
			out.WriteString(fmt.Sprintf("%d", M[i][j]))
		}
		out.WriteString("\n")
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}

C++: #include <iostream>

using namespace std;

const static 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--;
        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];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include<iostream>

int main() {
	int node_num, adj[100][100];

	std::cin >> node_num;

	for (int i = 0; i < node_num; i++)
		for (int j = 0; j < node_num; j++)
			adj[i][j] = 0;

	for (int i = 0; i < node_num; i++) {
		int node, num;
		std::cin >> node >> num;
		for (int j = 0; j < num; j++) {
			int n;
			std::cin >> n;
			adj[node][n - 1] = 1;
		}
	}

	for (int i = 0; i < node_num; i++) {
		for (int j = 0; j < node_num; j++) {
			std::cout << adj[i][j] << (j != node_num - 1 ? " ":"");
		}
		std::cout << std::endl;
	}
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N]; // 0 オリジンの隣接行列
	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--; // 0 オリジンへ変換
			M[u][v] = 1; // u と v の間に辺を張る
		}
	}
	
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			if ( j ) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	
	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[i][ln[i][j]-1] = 1;
	    }
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
	{
	  cout << m[i][j];
	  if(j!=n-1)
	    {
	      cout << " ";
	    }
	}
      cout << endl;
    }
  return 0;
}

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

#define WHITE 0   // not visited yet.
#define GRAY 1    // visited, but not completed.
#define BLACK 2   // search completed.

int G[101][101];        // adjacency list.
int color[101];         // visited/completed sign.
int n;                  // size.
int d[101], f[101], t;  // first visit time/complete time.

void search_loop(int i) 
{
    int next;
    d[i] = ++t;
    color[i] = GRAY;  // first visited.

    for(next = 1; next <= n; next++){
        if(i == next && G[i][i] > 0) break;   // if self-looped, through.
        if(G[i][next] > 0 && color[next] == WHITE){  // if not visited yet, visit.
            search_loop(next);
        }
    }
    f[i] = ++t;
    color[i] = BLACK;  // completed. 

    return;
}

void dfs()
{
    int i;
    for(i = 1; i <= n; i++) color[i] = WHITE;  // initialize.
    t = 0;

    for(i = 1; i <= n; i++) if(color[i] == WHITE) search_loop(i);

    for(i = 1; i <= n; i++) cout << i << " " << d[i] << " " << f[i] << endl;

    return ;
}

int main()
{
    int i, j, k, e;
    cin >> n;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){ G[i][j] = 0; } }

    do{
        cin >> i >> e;
        for(j = 1; j <= e; j++){
            cin >> k;
            G[i][k] = 1;
        }
    }while(i < n);

    dfs();
    return 0;
}

C++: #include<iostream>
using namespace std;
int map[101][101];
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int m;
		cin >> m;
		for (int j = 0; j < m; j++) {
			int b;
			cin >> b;
			map[a][b] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j != 1) cout << " ";
			cout << map[i][j];
		}
		cout << endl;
	}
}

C++: #include <iostream>
#define N 100

using namespace std;

int main(int argc, char const *argv[]) {
    int n, u, k, v;
    int A[N][N] = {0};

    cin >> n;
    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 < u; i++){
        for (int j = 0; j < u - 1; j++){
            cout << A[i][j] << ' ';
        }
        cout << A[i][u-1] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;

int main() {
  cin >>N;
  vector<vector<bool>> A(N, vector<bool>(N, 0));
  rep(i, N){
    int u,k; cin >>u >>k; u--;
    rep(j, k){
      int x; cin >>x; x--; A[u][x] = 1;
    }
  }
  rep(i, N){
    rep(j, N){
      cout <<A[i][j];
      if (j == N-1) cout <<endl;
      else cout <<" ";
    }
  }
}

C++: #include<iostream>
using namespace std;
int main()
{
    int hh[108][108];
    int n,m,u,v;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            hh[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cin>>u>>m;
        for(int j=1;j<=m;j++)
        {
            cin>>v; hh[u][v]=1;
        }


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