Go: package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}

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

int main(void){
    int n; cin >> n;
    bool graph[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) graph[i][j]=false;
    }
    for(int i=0; i<n; i++){
        int v,k; cin >> v >> k;
        for(int j=0; j<k; j++){
            int w; cin >> w;
            graph[v-1][w-1]=true;
        }
    }

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

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

int main(){

    ll N;
    cin >> N;

    vector<vector<ll> > G(N,vector<ll>(N,0));
    for (int i = 0; i < N; i++)
    {
        ll u,k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            ll 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;
        
    }
    
    




}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

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

	int n;
	cin >> n;

	int g[n][n] = {};
	for(int i=0;i<n;i++){
		int u, nume;
		cin >> u >> nume;

		int v;
		for(int j=0;j<nume;j++){
			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 << "\n";
	}
	
	return 0;
}

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

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

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

    return 0;
}

C++: 
import java.util.Scanner;
import java.util.ArrayList;


class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}

	void solve(){
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int [][] ar = new int[n][n];

		for(int i = 0; i < n; i++){
			int u = in.nextInt() - 1, k = in.nextInt();
			for(int j = 0; j < k; j++){
				int v = in.nextInt() -1;
				ar[u][v] = 1;
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(j != 0) System.out.print(" ");
				System.out.print(ar[i][j]);
			}
			System.out.println("");
		}

	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  
 //とても大きい値を無限としておく。
  int n;
  cin >> n;  //Vは与えられた頂点数,Eは辺の数
  vector<vector<int>> a(n,vector<int>(n,0));//V*Vを無限で初期化
  for(int i=0;i<n;++i){
    int u,k;
    cin>>u>>k;
    u--;
    for(int j=0;j<k;++j){
      int v;
      cin>>v;
      v--;
      a[u][v]=1;
    }
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      cout<<a[i][j];
      if(j!=j-1){
        cout<<" ";
      }
    }
    cout<<endl;
  }
}

C++: #include <iostream>
using namespace std;
const int N = 100;

int main (){
    int M[N][N] = {0};
    int n,u,k,v;
    cin >> n;

    for (int i = 0; i < n ; ++i) {
     cin >> u >> k;
        u--; //0?????????????????????
        for (int j = 0; j < k ; ++j) {
            cin >> v;
            v -- ; // 0?????????????????????
            M[u][v] = 1; //u??¨v?????????????????????
        }
    }

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

    return 0;
}

C++: // C++ 14
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>

#define ll long long
#define loop(x, start, end) for(int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)

using namespace std;


int main(void) {
  int n, v, c, l;
  cin >> n;

  int mat[n][n];

  loop(i,0,n) {
    loop(j,0,n) {
      mat[i][j] = 0;
    }
  }

  loop(i, 0, n) {
    cin >> v >> c;
    loop(j,0,c) {
      cin >> l;
      mat[v-1][l-1] = 1;
    }
  }

  loop(i,0,n) {
    loop(j,0,n) {
      if (j) cout << " ";
      cout << mat[i][j];
    }
    cout << endl;
  }
}

C++: #include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n,u,k,p;
bool adm[105][105];
int main()
{
    memset(adm,false,sizeof(adm));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&u,&k);
        while(k--)
        {
            scanf("%d",&p);
            adm[u][p]=true;
        }
    }
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)printf("%d%c",adm[i][j]?1:0,j==n?'\n':' ');
    return 0;
}

C++: #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;
  }
 }
 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++) {
   cout << a[i][j] << ((j == N-1) ? "" : " ");
  }
  cout << endl;
 }
}

C++: #include<bits/stdc++.h>
using namespace std;
int M[111][111];
int main(){
  int n,u,k,v;
  cin>>n;
  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 <bits/stdc++.h>
using namespace std;

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

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

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n-1; j++){
      cout << ans[i][j] << ' ';
    }
    cout << ans[i][n-1] << endl;
  }

  return 0;
}

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

int main(){
	int n, u, k, v, A[MAX][MAX] = {};
	
	cin>>n;
	
	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<<(j==1?"":" ")<<A[i][j];
		}cout<<endl;
	}
	return 0;
}