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 <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <ctime>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int ans[101][101] = {0};
int main() {
	int n;
	cin >> n;
	int a;
	int b;
	int c;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			ans[i][c] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << ans[i][j];
			if (j != n)cout << " ";
			else cout << endl;
		}
	}
}

C++: /* 
 * ALDS1_11.cpp
 * ??£??\???????????¨?????§???????????????????????°??????G?????£??\????????¨?????????????????????????????????
 */
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

using Adjacents = vector<int>;
using Vertexes = vector<Adjacents>;

int main(void) {

    int N;
    scanf("%d", &N);

    Vertexes vs;
    vs.resize(N);
    for (int i = 0, id, num; i < N; ++i) {
        scanf("%d %d", &id, &num);
        for (int j = 0, vert; j < num; ++j) {
            scanf("%d", &vert);
            vs[id-1].push_back(vert);
        }
    }

    int **matrix = new int*[N];
    for (int i = 0; i < N; ++i) {
        matrix[i] = new int[N];
        memset(matrix[i], 0, sizeof(int)*N);
        for (int j = 0; j < vs[i].size(); ++j) {
            matrix[i][vs[i][j] - 1] = 1;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            //printf("%2d", matrix[i][j]);
            putchar(matrix[i][j]);
            if (j != N - 1)
                putchar('\n');
        }
        delete[] matrix[i];
        printf("\n");
    }
    delete[] matrix;

    return 0;
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define NIL -1

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;

bool binary_search(int a[], int n, int key)
{
    int l = 0;
    int r = n;
    int middle;
    while (l < r)
    {
        middle = (l + r) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            l = middle + 1;
        }
        else if (key < a[middle])
        {
            r = middle;
        }
    }
    return false;
}

int main()
{
    int M[100][100];
    int n, u, k, v;

    cin >> n;

    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            M[i][j] = 0;
        }
    }

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

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

C++: #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int n,u,k,v;
	cin>>n;
	int G[110][110];
	memset(G,0,sizeof(G));
	for(int i=0;i<n;++i){
		cin>>u>>k;
		u--;//转化成0起点
		for(int j=0;j<k;++j){
			cin>>v;
			v--;
			G[u][v]=1;//u和v之间画一条边 
		} 
	} 
	for(int i=0;i<n;++i){
		for(int j=0;j<n;j++){
			if(j>0)cout<<' ';
			cout<<G[i][j]; 
		}
		cout<<endl;
	}
	//cout<<endl;
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<vector<int>> mat(n, vector<int>(n));
    rep(i, n) {
        int u, k, v;
        cin>>u>>k; u--;
        rep(j, k) {
            cin>>v; v--;
            mat[u][v] = 1;
        }
    }
    rep(i, n) {
        rep(j, n - 1) cout<<mat[i][j]<<" ";
        cout<<mat[i][n - 1]<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int T[100][100];

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

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

int main(){
	int n;
	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;
			if(T[v-1][u-1] == 0) T[u-1][v-1] = 1;	
		}
	}
	DispTable(n);
	return 0;
}

C++: #include"iostream"
#include"vector"
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector< vector<int> > matrix (n, vector<int>(n) );
  vector<int> visit;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)matrix[i][j]=0;
      int y;
      cin>>y;
      int num;
      cin>>num;
      for(int j=0;j<num;j++)
        {
          int x;
          cin>>x;
          matrix[y-1][x-1]=1;
        }
    }
  for(int i=0;i<n;i++)
    {
      cout<<matrix[i][0];
      for(int j=1;j<n;j++)
        {
          cout<<" "<<matrix[i][j];
        }
      cout<<endl;
    }
  return 0;
}

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

int main(){
    int N,u,k,x;
    cin>>N;
    
    int array[N][N];
    for(int i=0;i<N;i++){for(int j=0;j<N;j++){array[i][j]=0;}}
    
    for(int i=0;i<N;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>x;
            array[u-1][x-1]=1;
        }
    }
    
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(j!=0){
                    cout<<" ";
                }
                cout<<array[i][j];
            }
            cout<<"\n";
        }
        
        return 0;

}