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

C++: #include<iostream>

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[110][110]={0};
    int u,k,v;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        if(k==0)continue;
        for(int j=0;j<k;j++){
            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];
            if(j<n-1)cout<<" ";
        }
        cout<<""<<endl;
    }
    return 0;
}

C++: #include<stdio.h>
 
int main(){
  int i,j,n,u,k,v;
  int data[101][101];
  scanf("%d",&n);
  for( i = 1; i <= n; i++){
    for( j = 1; j <= n; j++){
      data[i][j]=0;
      }
  }
  for(i = 0; i < n; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      data[u][v]=1;
    }
  }
 
  for(i = 1;i <=n;i++ ){
    for(j = 1; j <=n;j++){
      if(j==n){
    printf("%d",data[i][j]);
      }else{
    printf("%d ",data[i][j]);
      }
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main(void) {

	int n, c, v;
	int G[SIZE][SIZE];
	int A[SIZE][SIZE];

	cin >> 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++) {
		cin >> v;
		cin >> c;
		for (int j = 0; j < c; j++) {
			cin >> G[i][j];
			int tmp = G[i][j];
			if (tmp > 0) {
				A[i][tmp - 1] = 1;
			}
		}
	}

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



}

C++: #include <stdio.h>
#define N 101

int main(){

  int u,k,i,j,v,n;
  int a[N][N];
  
  scanf("%d",&n);

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

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

  return 0;

}

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

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

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

    return 0;
}

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

int G[101][101];

int main()
{
	int n, i, j, a, b, e;
	scanf("%d", &n);
	for(i = 1; i <= n; i++){
		for(j = 1; j <= n; j++){
			G[i][j] = 0;
		}
	}
	for(i = 1; i <= n; i++){
	    scanf("%d %d", &a, &e);
		for(j = 1; j <= e; j++){
			scanf("%d", &b);
			G[a][b] = 1;
		}
	}
	for(i = 1; i <= n; i++){
		printf("%d", G[i][1]);
		for(j = 2; j <= n; j++){
			printf(" %d", G[i][j]);
		}
		printf("\n");
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

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

	rep(i,n){
		int u,k;
		cin >> u >> k;	
		u--;
		rep(j,k){
			int v;
			cin >> v;
			v--;
			ans[u][v]=1;
		}
	}

	rep(i,n){
		rep(j,n-1){
			cout << ans[i][j] << " ";	
		}
		cout << ans[i][n-1] << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
using namespace std;

int main(){
    int n;
    int A[100+1][100+1];

    cin>>n;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            A[i][j]=0;
        }
    }

    rep(i,n){
        int u,k;
        cin>>u>>k;
        rep(j,k){
            int v;
            cin>>v;
            A[u][v]=1;
        }
    }

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


    return 0;
}

C++: //
//  main.cpp
//
// g++ -std=c++14 main.cpp
//

//#include "main.hpp"
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <tuple>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin >> n;
    
    bool ans[105][105] = {};
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            ans[u - 1][v - 1] = true;
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }
}
// g++ -std=c++14 main.cpp

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

class Adjl{
private:
	int u;
	int k;
	int *v;
public:
	Adjl(int u, int k);
	~Adjl(){ delete[] v; }
	void setV(int vk);
	void printAdjm(int n);
};

Adjl::Adjl(int u, int k)
{
	this->u = u;
	this->k = 0;
	v = new int[k];
}

void Adjl::setV(int vk)
{
	v[k] = vk;
	k++;
}

void Adjl::printAdjm(int n)
{
	int j = 0;
	for (int i = 1; i <= n; i++) {
		if (j < k && v[j] == i) {
			cout << "1";
			j++;
		}
		else {
			cout << "0";
		}
		if (i < n) cout << " ";
		else cout << endl;
	}
}

int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		Adjl *adjl = new Adjl(u, k);
		for (int j = 0; j < k; j++) {
			int vk;
			cin >> vk;
			adjl->setV(vk);
		}
		adjl->printAdjm(n);
		delete adjl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
    int num, num1, numb2, list1;
    cin >> num;
    bool matrix[num][num] = {};
    for(int i = 0; i < num; i++) {
        cin >> num1 >> numb2;
        for(int i = 0 ; i < numb2; i++) {
            cin >> list1;
            matrix[num1 - 1][list1 - 1] = 1;
        }
    }
    for(int i = 0 ; i < num; i++) {
        for (int p = 0; p < num; p++) {
            if (p != num -1) {
                cout << matrix[i][p] << " ";
            } else cout<<matrix[i][p] << endl;
        }
    }
}

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

int main(){
    int n,a[101][101],u,k,v;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            a[i][j]=0;
        }
    }
    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<<a[i][j]<<((j==n)?'\n':' ');
        }
    }
}