Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

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

int main()
{
	int n, u, k, v[101], VM[101][101];
	memset(VM, 0, sizeof(VM));
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> u >> k;

		for (int j = 1; j <= k; j++)
		{
			cin >> v[j];
			VM[u][v[j]] = 1;
		}
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j < n; j++)
			cout << VM[i][j] << " ";

		cout << VM[i][n] << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int G[100][100];

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

	return 0;
}

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

int main() {
    int n, idx, g_num, a;
    int G[MAX+1][MAX+1];

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> idx >> g_num;
        for(int j=0; j<=n; j++) {
            G[idx][j] = 0;
        }
        for(int j=0; j<g_num; j++) {
            cin >> a;
            G[idx][a] = 1;
        }   
    }

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

    return 0;
}

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

int main() {

	int n;
	std::cin >> n;

	std::vector<std::vector<int>> g(n,std::vector<int>(n,0));

	for (int i{}; i < n; ++i) {
		int u, k;
		std::cin >> u >> k;
		for (int ki{}; ki < k; ++ki) {
			int vi;
			std::cin >> vi;
			g[u - 1][vi - 1] = 1;
		}
	}

	if(n>1)
	for (const auto&e : g) {
		std::copy(
			std::begin(e)
			, std::prev(std::end(e))
			, std::ostream_iterator< const std::decay_t<decltype(e)>::value_type &>{std::cout, " "}
		);
		std::cout << *( std::end(e)-1 ) << "\n";
	}
	else
		for (const auto&e : g) {
			for (const auto&ee : e)
				std::cout << ee << "\n";
		}

	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int list[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      list[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    int u,k,to;
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>to;
      to--;
      for(int l=0;l<n;l++){
	if(l==to){
	  list[u][l]=1;
	}else{
	}
      }
    }
  }
  //print
  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
      cout<<list[i][j]<<" ";
    }
    cout<<list[i][n-1]<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

#define N 100

int M[N][N];

int main(){
    int n,u,k,v;
  
    cin >> n;
    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){
            // 2個目からは空白が必要
            if(j){
                cout << " ";
            }
            cout << M[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

C++: #include <iostream>
using namespace std;
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;i<n;j++) M[i][j]=0;
  }
  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<n;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 << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> p;


int main(){
  int n,a,b,c;
  cin >> n;
  int v[n][n];
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<b;j++){
      cin >> c;
      v[a-1][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i][j]!=1)cout << 0 << ' ';
      else cout << v[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	int n;
	int u, k, v;
	int gra[101][101] = {};

	cin >> n;
	
	FOR(i, 1, n) {
		cin >> u >> k;
		FOR(t, 1, k) {
			cin >> v;
			gra[u][v] = 1;
		}
	}
	FOR(i, 1, n) {
		FOR(t, 1, n) {
			cout << gra[i][t];
			if (t != n) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
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--;
        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;
    }
}

C++: #include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG


int main()
{
  int n;
  cin >> n; cin.ignore();

  DPRINTF("num of nodes: %d\n", n);

  bool graph[n][n];

  // init
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      graph[i][j] = 0;

  // make a graph
  for (int i = 0; i < n; i++)
  {
    int node;
    int degree;

    cin >> node >> degree;

    DPRINTF("node %d (degree %d)\n", node, degree);

    for (int j = 0; j < degree; j++)
    {
      int adj; cin >> adj;

      // note that index starts from #0 though node and adj from #1
      graph[node - 1][adj - 1] = true;
    }

    cin.ignore();
  }

  // print a graph as a matrix form
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (j == 0)
        printf("%d", graph[i][j]);
      else
        printf(" %d", graph[i][j]);
    }
    cout << endl;
  }

  return 0;
}