Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: #include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n,u,k,p;
bool adm[105][105];
int main()
{
    memset(adm,false,sizeof(adm));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&u,&k);
        while(k--)
        {
            scanf("%d",&p);
            adm[u][p]=true;
        }
    }
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)printf("%d%c",adm[i][j]?1:0,j==n?'\n':' ');
    return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
 int N;
 cin >> N;
 int a[N][N];
 for (int i=0; i<N; i++) {
  for (int j=0; j<N; j++) {
   a[i][j] = 0;
  }
 }
 for (int i=0; i<N; i++) {
  int u,k;
  cin >> u >> k;
  for (int j=0; j<k; j++) {
   int v;
   cin >> v;
   a[u-1][v-1] = 1;
  }
 }
 for (int i=0; i<N; i++) {
  for (int j=0; j<N; j++) {
   cout << a[i][j] << ((j == N-1) ? "" : " ");
  }
  cout << endl;
 }
}

C++: #include<bits/stdc++.h>
using namespace std;
int M[111][111];
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++){
      if(j) cout<<' ';
      cout<<M[i][j];
    }
    cout<<endl;
  }
  return(0);
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<vector<int> > ans(n, vector<int>(n, 0));

  for(int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for(int j = 0; j < k; j++) {
      int adj;
      cin >> adj;
      ans[u-1][adj-1] = 1;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n-1; j++){
      cout << ans[i][j] << ' ';
    }
    cout << ans[i][n-1] << endl;
  }

  return 0;
}

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

int main(){
	int n, u, k, v, A[MAX][MAX] = {};
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>u>>k;
		for(int j = 0; j < k; j++){
			cin>>v;
			A[u][v] = 1;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cout<<(j==1?"":" ")<<A[i][j];
		}cout<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
	int n;
	cin >> n;
	vector<int> Adj[n];
	rep(i, n) {
		int it, k;
		cin >> it >> k;
		it--;
		rep(j, k) {
			int x;
			cin >> x;
			x--;
			Adj[it].push_back(x);
		}
	}

	vector<vector<int>> G(n, vector<int>(n, 0));
	rep(i, n){
		for(auto y : Adj[i]){
			G[i][y] = 1;
		}
	}
	rep(i, n) {
		rep(j, n - 1) cout << G[i][j] << " ";
		cout << G[i][n - 1] << endl;
	}
	return 0;
}

C++: n=gets.to_i;
a=Array.new(n){Array.new(n,0)}
m=Array.new
n.times do |i|
  m.clear
  m=gets.split.map{|i|i.to_i}
  m[1].times do |j|
    a[m[0]-1][m[j+2]-1]=1
  end
end
n.times do |i|
  print a[i],"\n"
end

C++: #include<iostream>
using namespace std;
int main(){
  int graph[100][100]={},n,u,k,v;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>u>>k;
    for(int j=0;j<k;++j){
      cin>>v;
      graph[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      if(j) cout<<" ";
      cout<<graph[i][j];
    }
    cout<<endl;
  }
  return 0;
}

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

void solve()
{
    using namespace std;

    int n;
    cin >> n;

    vector<vector<bool>> edges(n, vector<bool>(n));

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

        for (int j = 0; j < k; ++j)
        {
            int v;
            cin >> v;
            edges[u - 1][v - 1] = true;
        }
    }

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

int main()
{
    solve();
    return 0;
}

C++: /*  2019 6/23
    A Graph
*/

#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--;  // 0 origin

        for (int j = 0; j < k; ++j) {
            cin >> v;
            v--;

            M[u][v] = 1;
        }
    }

    // output
    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>
using namespace std;

int n;
int M[101][101];
int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int v, k;
        cin >> v >> k;
        for (int j = 0; j < k; ++j) {
            int s;
            cin >> s;
            M[v][s] = 1;
        }
    }

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

    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
int main(){
	int n;
	int a, b;
	int A[101];
	int **arr = NULL;
	scanf("%d", &n);	
	arr = new int*[n];
	for (int i = 0; i < n; i++){
		arr[i] = new int[n];
	}
	for (int i = 0; i < n; i++){		
		scanf("%d%d", &a, &b);
		for (int j = 0; j < b; j++){
			scanf("%d",&A[j]);
			arr[a-1][A[j]-1] = 1;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (j == n - 1){
				if (arr[i][j] == 1){
					printf("1");
				}
				else {
					printf("0");
				}
			}
			else {
				if (arr[i][j] == 1){
					printf("1 ");
				}
				else {
					printf("0 ");
				}
			}
		}
		printf("\n");
	}
	for (int i = 0; i < n; i++){
		delete[](arr[i]);
	}
	delete[](arr);
	return 0;
}

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

int v[N + 1][N + 1];

int main()
{
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            v[i][j] = 0;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        int u, k;
        std::cin >> u >> k;
        for (int j = 0; j < k; ++j)
        {
            int t;
            std::cin >> t;
            v[u][t] = 1;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (j > 1)
            {
                std::cout<<' ';
            }
            std::cout << v[i][j];
        }
        std::cout << "\n";
    }
}

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

int main(){

  int n,k,v,u;
  cin>>n;

  double V[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

      V[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    cin>>u;
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      V[u-1][v-1]=1;
    }


  }

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

  return 0;
}