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 <stdio.h>
#define N 100
int main(){
  int n,i,j,u,k,v,M[N][N];

  scanf("%d",&n);

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

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

    for(i=0 ; i<n ; i++)
    {
      for(j=0 ; j<n-1 ; j++)
	{
	  printf("%d ",M[i][j]);
	}
      printf("%d",M[i][n-1]);
      printf("\n");
    }
  
  return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

#include<string>
#include<cmath>
#include<map>
//#include<cstdlib>
#include<deque>
#include<queue>
#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j];
      if(j!=N-1) cout << " ";
      else cout << endl;
    }
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}

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

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
    vector<int> l[101];
    int matrix[100][100];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            int tmp;
            cin>>tmp;
            l[u].push_back(tmp);
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            matrix[i][j]=0;
        }
    }
    
    for(int i=1;i<n+1;i++)
    {
        for(int j=0;j<l[i].size();j++)
        {
            matrix[i-1][l[i][j]-1]=1;
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<matrix[i][j]<<" ";
        }
        cout<<endl;
    }
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

#define MAX_N 100

int G[MAX_N][MAX_N];

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  rep(i, n) {
    int u, k;
    cin >> u >> k;
    rep(j, k) {
      int node_num; cin >> node_num;
      G[u][node_num] = 1;
    }
  }
  REP(i, 1, n + 1) {
    REP(j, 1, n + 1) {
      if (j != 1) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }
  return 0; 
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100

int n;
int G[MAX][MAX];

void init();

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

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

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

void init(){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            G[i][j] = 0;
        }
    }
}

C++: #include <algorithm>
#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;
  }
  while (n>0) {
    int u;
    cin >> u;
    int k;
    cin >> k;
    int v;
    while (cin>>v && k>0) {
      A[u-1][v-1] = 1; //??\???
      k--;
    }
    n--;
  }
  for (int i=0; i<n; i++) { //??????
    for (int j=0; j<n-1; j++)
      cout << A[i][j] << " ";
    cout << A[i][n-1] << endl;
  }
}

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

int main(){
	std::vector< std::vector<int> > M;
	int n, r, k, c;
	scanf("%d", &n);
	M.resize(n);
	for (int i=0;i<n;i++){
		M[i].resize(n);
		scanf("%d %d", &r, &k);
		for (int j=0; j<k;j++){
			scanf("%d", &c);
			M[i][c-1]=1;
		}
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			printf("%d", M[i][j]);
                        if (i!=n) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<vector<int> > A(n + 1, vector<int> (n + 1));
  
  int u, k;
  
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int adju;
      cin >> adju;
      A.at(u - 1).at(adju - 1) = 1;
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << A.at(i).at(j);
      if (j == n - 1) {
        cout << endl;
      }
      else {
        cout << " ";
      }
    }
  }
}

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

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

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

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

#define N 100
int A[N][N];
int u,k,v;

int main(void){
	
	int i,j;
	int n;
	cin >> n;	
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			A[i][j] = 0;
		}
	}	

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

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




return 0;

}