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 <stack>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <utility>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int main() {
    int c;
    string s;
    getline(cin,s);
    c = atoi(&s[0]);
    int a[c][c];
    for(int i = 0;i<c;i++)
        for(int j = 0;j<c;j++)
            a[i][j] = 0;
    for (int i = 0; i <c;i++)
    {
        bool first = true;
        getline(cin, s);
        string::iterator ite = s.begin();
        while (ite != s.end() && *ite != '0')
        {
            if(*ite != ' ')
            {
                int n = atoi(&*ite);
                if(*(ite+1) != ' ' && ite+1 != s.end())
                {
                    n *= 10;
                    n += atoi(&*(++ite));
                    if(*(ite+1) != ' ' && ite+1 != s.end())
                    {
                        n*=10;
                        n+= atoi(&*(++ite));
                    }
                }
                if(first)
                    first = false;
                else
                    a[i][n-1] = 1;
            }
            ite++;
        }
    }
    for(int i = 0;i < c;i++)
    {
        for(int j = 0; j<c-1;j++)
        {
            cout << a[i][j] << " ";
        }
        cout << a[i][c-1] << endl;
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int n;
ll g[101][101];
int main(){
    cin >> n;
    rep(i,n){
        int u, k;
        cin >> u >> k;
        rep(j,k){
            int node;
            cin >> node;
            g[u][node] = 1;
        }
    }

    REP(i,1,n+1)REP(j,1,n+1)cout << g[i][j] << ((j == n)?"\n":" ");
    
    return 0;
}

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


using namespace std;


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


  vector< vector<int> > a;
  for(int i=0;i<n;i++){
    int u;
    int k;
    cin >> u >> k;
    vector<int> tmpa;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      tmpa.push_back(tmp);
    }

    a.push_back(tmpa);
  }

  
  
  // int a2[n][n]={0};

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a2[i][j]=0;
    }
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<(int)a[i].size();j++){
      a2[i][a[i][j]-1] = 1;
    }
  }

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

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

static const int N=100;

int main(){
   int n;cin>>n;
   int g[n+1][n+1];

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

   for(int i = 1; i < n+1; i ++) {
      int i_node; cin >> i_node;
      int deg; cin >> deg;
      rep(j, deg) {
        int j_node; cin >> j_node;
        g[i_node][j_node] = 1;
      }
   }

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

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

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

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

   int u, k, v;
   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 <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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main(){
	int n,in,inn;
	cin >> n;
	vector < vector <bool>> g(n, vector<bool>(n,false));
	rep(i, n) {
		cin >> in;
		cin >> in;
		rep(j, in) {
			cin >> inn;
			g[i][inn - 1] = true;
		}
	}
	rep(i, n) {
		rep(j, n) {
			cout << (g[i][j] ? 1 : 0) << (j != n - 1 ? " " : "") ;
		}
		cout << endl;
	}
}

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

bool find(vector<int> v, int j){
    bool e = false;
    for(vector<int>::iterator it = v.begin(); it!=v.end(); ++it){
        if (*it == j) e = true;
    }
    return e;
}

int main(){
    vector<int> adj[MAXN];
    int n; cin >> n;
    for(int i=1; i<=n; ++i){
        int l, m; cin >> l >> m;
        for(int j=0; j<m; ++j){
            int k; cin >> k;
            adj[l].push_back(k);
        }
    }
    
    for(int i=1; i<=n; ++i){
        for(int j=1; j<=n; ++j){
            cout << (find(adj[i], j) ? 1 : 0 ) << " ";
        }
        cout << endl;
    }
}

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

int main() {
    int N;
    int G[101][101];
    cin >> N;
    for (int j = 0; j <= N; ++j) for (int k = 0; k <= N; ++k) G[j][k] = 0;
    for (int _ = 0; _ < N; ++_) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int v; cin >> v;
            G[u][v] = 1;
        }
    }

    for (int j = 1; j <= N; ++j) {
        for (int k = 1; k <= N; ++k) {
            if (k > 1) cout << " ";
            cout << G[j][k];
        }
        cout << endl;
    }

    return 0;
}