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 <cstdio>
using namespace std;

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

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

int main() {
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int n, u, k, v;
    std::cin >> n;
    for (int i=0; i<n; i++) {
        std::cin >> u >> k;
        int vv[100]={};
        for (int j=0; j<k; j++) {
            std::cin >> v;
            vv[v-1]=1;
        }
        for (int j=0; j<n; j++) {
            std::cout << vv[j];
            if (j == n-1) {
                std::cout << "\n";
            } else {
                std::cout << " ";
            }
        }
    }

    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;
            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;
    }
    
}

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

int main()
{
    int n;
    int graph[105][105] = {};

    cin >> 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;
            graph[u][v] = 1;
        }
    }
    
    for ( int i = 1; i <= n; i++ ) {
        cout << graph[i][1];
        for ( int j = 2; j <= n; j++ ) {
            cout << " " << graph[i][j];
        }
        cout << endl;
    }

    return ( 0 );
}

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

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

	static int M[101][101];
	int n;
	cin >> n;

	int u, k, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			M[u][v] = 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++: /* 
 * 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] + '0');
            if (j != N - 1)
                putchar(' ');
        }
        delete[] matrix[i];
        printf("\n");
    }
    delete[] matrix;

    return 0;
}

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

int main(){
	int n,array[100][100],a,b,c;
	for(int i = 0;i < 100;++i){
		for(int j = 0;j < 100;++j){
			array[i][j] = 0;
		}
	}
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> a >> b;
		for(int j = 0;j < b;++j){
			cin >> c;
			array[a - 1][c - 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 << endl;
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;

int main() {
	vector<vector<int>> adjM;
	int N;
	cin >> N;
	adjM.resize(N);
	for (int i = 0; i < N; ++i) {
		adjM[i].resize(N);
	}

	for (int i = 0; i < N; ++i) {
		int v, g;
		cin >> v;
		cin >> g;
		for (int j = 0; j < g; ++j) {
			int k;
			cin >> k;
			adjM[v - 1][k - 1] = 1;
		}
	}

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N - 1; ++j) {
			cout << adjM[i][j] << " ";
		}
		cout << adjM[i][N - 1] << endl;
	}

	return 0;
}

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

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


	for(int i=0;i<n;++i){

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

		int m,k; //k=number of adj
		cin>>m>>k;
		assert(m==i+1);

		for(int j=0;j<k;++j){
			int adj;
			cin>>adj;
			if(adj){
				A[i][adj-1]=1;
			}
		}
	}

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

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                if(vec[i][k]==j) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }cout << endl;
}

C++: #include <cstdio>
#include <vector>

int main(){
	std::vector< std::vector<int> > M;
	int n, r, k, c;
	scanf("%d", &n);
	M.resize(n);
	for (int i=0;i<n;i++){
		M[i].resize(n);
		scanf("%d %d", &r, &k);
		for (int j=0; j<k;j++){
			scanf("%d", &c);
			M[i][c-1]=1;
		}
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			printf("%d ", M[i][j]);
		}
		printf("\n");
	}
	return 0;
}