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] {
			if j == n-1 {
				fmt.Printf("%d\n", Adj[i][j])
				continue
			}
			fmt.Printf("%d ", Adj[i][j])
		}
	}
}

C++: #include <cstdio>
#include <cstring>

const int MAX = 100;
int adj[MAX + 1][MAX + 1];

int main()
{
  std::memset(adj, 0, sizeof(adj));

  int n;
  scanf("%d", &n);

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

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

  return 0;
}

C++: #include <iostream>
using namespace std;
int mat[101][101];

int main(){
  int n;
  cin >> n;
  for (int i=0;i<n;i++){
    int id,k;
    cin >> id >> k;
    for (int j=0;j<k;j++){
      int temp;
      cin >> temp;
      mat[id][temp] = 1;
    }
  }
  for (int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if (j!=1)
        cout << " ";
      cout << mat[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vector<vi> a(n);
    REP(i,n) {
        int m;
        cin>>m>>m;
        REP(j,m) {
            int v;
            cin>>v;
            a[i].push_back(v-1);
        }
    }

    REP(i,n) {
        REP(j,n) {
            cout<<(find(ALL(a[i]),j)!=end(a[i]));
            if(j!=n-1) cout<<" ";
            else cout<<endl;
        }
    }
    return 0;
}

C++: // 無向グラフの作成

#include <iostream>
#include <algorithm>
using namespace std;
static const int N = 100; // 配列の最大次元

int main() {
	int M[N][N]; // 0オリジンの隣接配列
	int n, u, k, v;

	cin >> n;

	// 隣接配列を0で初期化
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}


	// 無向グラフを作成する(u-v間に辺を張る、配列番号u-vに1を立てる)
	for (int i = 0; i < n; i++) {
		cin >> u >> k; // 頂点番号u, 出次数k
		u--;
		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++: #include <stdio.h>

int map_max;
int map[100][100];
int rows;
int cols[100];
int mat[100][100];

void get_map();
void print_map();
void conv_map();
void print_mat();

int main()
{

  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}

void get_map()
{

  int k;
  scanf("%d", &map_max);//<100

  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
	{
	  map[i-1][j-1]=0;
	  scanf("%d", &map[i-1][j-1]);
	}
    }

  
  return ;
}

void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  printf("%d", map[i-1][j-1]);
	}
      puts("");
    }
return ;
}


void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  mat[i][map[i-1][j-1]-1]=1;
	}
    }
  return ;
}

void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
	{
	  printf("%d ", mat[i][j]);
	}
      puts("");
    }
}

C++: #include <iostream>

using namespace std;



int main(){

  int n,u,k,x;
  int array[124][124] = {{}};
  cin >> n;



  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> x;
      array[u - 1][x - 1] = 1;
    }
  }
  for (int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      if(j == n - 1) cout << array[i][j];
      else cout << array[i][j] << " ";
    }
    cout << endl;
  }
}