Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;

bool mx[105][105];

int main() {
	int n;
	cin >> n;
	Loop1(i, n) {
		Loop1(j, n) {
			mx[i][j] = 0;
		}
	}
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(j, k) {
			int v;
			cin >> v;
			mx[u][v] = 1;
		}
	}
	Loop1(i, n) {
		Loop1(j, n) {
			cout << mx[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

C++: #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--;
    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>
#include <cstdio> 
using namespace std;
/*---------------------------------------------------*/

int main(){
  int n,u,k,v;
  int g[100][100]={};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(int i=0;i<k;i++){
      scanf("%d",&v);
      g[u][v]=1;
    }
  }
  for(int i=1;i<n+1;i++){
    printf("%d",g[i][1]);
    for(int j=2;j<n+1;j++){
      printf(" %d",g[i][j]);
    }
    printf("\n");
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=2e12;
ll cnt=0;
#define max 100005
#define nil -1


int main(){
  int n,q,w,e;
  int m[105][105];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>q>>w;
    for(int j=1;j<=n;j++)m[i][j]=0;
    for(int j=1;j<=w;j++){
      cin>>e;
      m[i][e]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(j!=1)cout<<' ';
      cout<<m[i][j];
    }
    cout<<endl;
  }
   return 0;
}

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

int n;
int k;


int main(){
  int num;
  cin>>n;
  int adj[n][n];
  int rin;
  int i=0,j=0;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    cin>>num>>k;
    num--;
    for(j=0;j<k;j++){
      cin>>rin;
      rin--;
      adj[num][rin]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<adj[i][j];
    }
    cout<<endl;
  }
  return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<vector<int>> graph(n, vector<int>(n, 0));
    rep(i, n) {
        int vertex, num;
        cin >> vertex >> num;
        rep(j, num) {
            int adjcent;
            cin >> adjcent;
            graph[vertex - 1][adjcent - 1] = 1;
        }
    }

    for (auto row : graph) {
        for (size_t i = 0; i < row.size(); i++) {
            cout << row[i];
            if (i != row.size() - 1) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }
}

C++: #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--;
        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 > 0) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int g[101][101];
int main(){
    int n,u,k,v;
    cin>>n;
    rep(i,n){
        cin>>u>>k;
        --u;
        rep(j,k){
            cin>>v;
            --v;
            g[u][v]=1;
        }
    }
    rep(i,n){
        rep(j,n) cout<<g[i][j]<<(j==n-1?"":" ");
        cout<<endl;
    }
    return 0;
}

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

int main(void){
  int m, a[100][100];
  int b[100][100]={0};

  cin >> m;

  for(int i=0; i<m; i++){
    cin >> a[i][0];
    cin >> a[i][1];

    for(int j=2; j<a[i][1]+2; j++){
      cin >> a[i][j];
      b[i][ a[i][j]-1 ] = 1;
    }
  }

  for(int i=0; i<m; i++){
    cout << b[i][0];
    for(int j=1; j<m; j++){
      cout << " " << b[i][j];
    }
    cout << "\n";
  }
  return 0;
}

C++: #include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int mp[10000][10000]={};

signed main(){
  int n,u,k;
  cin>>n;
  int ad_m[100][100]={};
  rep(i,n){
    cin>>u>>k;
    rep(j,k){
      int v;
      cin>>v;
      v--;
      ad_m[i][v]+=1;
    }
  }
  rep(i,n){
    rep(j,n){
      cout<<ad_m[i][j];
      if(j<n-1)cout<<' ';
    }
    cout<<endl;
  }


  return 0;

}

C++: #include<iostream>

using namespace std;

#define ll long long

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

    for (ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            cout << A[i][j];
        }
        if(i<n-1){
            cout << '\n';
        }
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

#define ll long long
typedef complex<double> P;

int main() {
  int n; cin >> n;
  int adj[n][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;
      adj[u-1][v-1] = 1;
    }

  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << adj[i][j] << (j == n-1 ? '\n' : ' ');
    }
  }
}