Go: package main
import (
	"fmt"
	"bufio"
	"os"
	"bytes"
	"strconv"
	"strings"
)

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num , _ :=  strconv.Atoi(scanner.Text())
	return num
}


func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	N := nextInt(scanner)
	var A [][]int = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = make([]int, N)
	}
	for i:=0; i<N; i++{
		idx := nextInt(scanner)
		cnt := nextInt(scanner)
		for j:=0; j<cnt; j++ {
			node := nextInt(scanner)
			A[idx-1][node-1] = 1
		}
	}
	var outBuffer bytes.Buffer
	for i:=0; i<N; i++ {
		outBuffer.WriteString(strings.TrimRight(fmt.Sprintf("%v",A[i])[1:], "]") + "\n")
	}
	fmt.Printf("%s", outBuffer.String())
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[105][105]={};
  cin >> 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;
      a[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout << " " ;
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include<cstdio>
const int max_n = 100;
int main(){
	int n;
	int u,k,v;
	int G[100][100];
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			G[i][j] = 0;
		}
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&u,&k);
		for(int j=1;j<=k;j++){
			scanf("%d",&v);
			G[u-1][v-1] = 1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			printf("%d",G[i][j]);
			if(j!=n-1) printf(" ");
			else if(j == n-1) printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

int N;

int main()
{
	cin >> N;

	vector<vector<bool> > M(N, vector<bool>(N));

	int u, k, v;

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

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

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

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N;)
		{
			cout << M[i][j];

			cout << ' ';
		}

		cout << endl;
	}

	return 0;
}

C++: #include <stdio.h>

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

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]);
	  if(j!=map_max-1)
	    {
	      printf(" ");
	    }
	}
      printf("\n");
    }
}

C++: #include<vector>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<vector<int>>v(n);
	for (int i = 0; i < n; i++)
	{
		int u;
		cin >> u;
		v[i].push_back(u);
		int k;
		cin >> k;
		v[i].push_back(k);
		for (int j = 0; j < k; j++)
		{
			int number;
			cin >> number;
			v[i].push_back(number);
		}
	}
	vector <vector<int>>answer(n, vector<int>(n));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			answer[i][j] = 0;
		}

	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < v[i].size()-2; j++)
		{
			answer[v[i][0]-1][v[i][2 + j]-1 ]= 1;
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n-1; j++)
		{
			cout << answer[i][j]<<" ";
		}
		cout << answer[i][n - 1] << endl;
		
	}
}
/*
1 2 2 4
2 1 4
3 0
4 1 3


*/

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,W;
int vx[]={1,0,-1,0};
int vy[]={0,1,0,-1};
int mt[102][102];
using namespace std;
void solve(){
    cin >> N ;
    int E,K;
    memset (mt,0,102*102);
    REP(i,N){
      cin >> E >> K;
      REP(j,K)
      {
        cin >> E;
        mt[i][E-1] = 1 ;
      }
    }
    REP(x,N){
      REP(y,N){
        cout << mt[x][y] << " ";
      }
      if(x!=N-1)cout << endl;
    }
}
int main(){

    solve();
}

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

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

  vector<int> c(n);
  vector<vector<int>> M(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    int node;
    int d;
    cin >> node >> d;
    node--;

    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      M[i][tmp] = 1;
    }
  }

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

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

static const int N = 100;

int main(void) {
	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>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int g[n + 1][n + 1];
    //?????????
    for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= n; j++) {
	    g[i][j] = 0;
	}
    }
    //input
    for (int i = 1; i <= n; i++) {
	int a;
	cin >> a;
	int b;
	cin >> b;
	for (int j = 1; j <= b; j++) {
	    int c;
	    cin >> c;
	    g[a][c] = 1;
	}
    }
    for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= n; j++) {
	    cout << g[i][j];
	    if (j != n) {
		cout << " ";
	    }
	}
	cout << endl;
    }
    return 0;
}

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

int AdjM[101][101];

int main(){
    int N;
    cin>>N;
    int id,edgnum,adj;
    for(int i=0;i<N;++i){
        cin>>id;
        cin>>edgnum;
        for(int j=0;j<edgnum;++j){
            cin>>adj;
            AdjM[id-1][adj-1]=1;
        }

    }

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(j!=N-1){
                cout<<AdjM[i][j]<<" ";
            }
            else if(j==N-1){
                cout<<AdjM[i][j]<<"\n";
            }
        }
    }
}

C++: #include <stdio.h>

#define NMAX 100

int main() {
    int M[NMAX + 1][NMAX + 1];
    int n, k, a, b;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            M[i][j] = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &a, &k);
        for (int j = 0; j < k; j++) {
            scanf("%d", &b);
            M[a][b] = 1;
        }
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            printf("%d%c", M[i][j], j == n ? '\n' : ' ');
    return 0;
}

C++: //Graph
#include <iostream>

using namespace std;

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

    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v;
            M[u][v] = 1;
        }
    }
    for(int i=1; i<n+1; i++) {
        for(int j=1; j<n; j++)
            cout << M[i][j] << " ";
        cout << M[i][n] << endl;
    }
}