Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: #include <iostream>
#define LIST_SIZE 100

using namespace std;

int main(){
    int n, u, k, v, adj[LIST_SIZE][LIST_SIZE] = {};

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

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

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

  int n,u,k,v,graph[101][101]={{}};

  cin >> n ;

  for(int i = 0; i < n; i++){
    cin >> u >> k ;
    for(int j = 0; j < k ; j++){
      cin >> v;
      graph[u][v] = 1;
    }
  }

  for(int i = 1; i<= u; i++){
    for(int j = 1; j<= u; j++){
      cout << graph[i][j] << ' ' ; 
    }
    cout << endl;
  }


  return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> mat(n,vector<ll>(n,0));
    for(ll i=0;i<n;i++) {
        ll u,k;
        cin>>u>>k;
        for(ll j=0;j<k;j++) {
            ll tmp;
            cin>>tmp;
            mat[u-1][tmp-1] = 1;
        }
    }
    for(ll i=0;i<n;i++) {
        for(ll j=0;j<n;j++) {
            if(j<n)cout << mat[i][j] << " ";
            else cout << mat[i][j] << " ";
        }
        cout << endl;
    }
}

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

typedef long long ll;
typedef int64_t in;
using namespace std;
#define INF 1000000007
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)


int main() {
    int n; cin >> n;
    int u,k,v;
    int a[n][n] = {};
    rep(i,n){
        cin >> u >> k;
        rep(j, k){
            cin >> v;
            a[i][v-1]++;
        }
    }
    rep(i,n){
        rep(j,n){
            if(j!=n-1) cout << a[i][j] << " ";
            else cout << a[i][j] << endl;
        }
    }
}

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

int A[101][101];

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

C++: #include <iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	int u,k;
	int v[k];
	int G[N][N];
	for(int i=0;i<N;++i)
		for(int j=0;j<N;++j)
			G[i][j]=0; //?????????
	for(int i=0;i<N;++i){
		cin>>u>>k;
		for(int j=0;j<k;++j){
			cin>>v[j];
			G[v[j]-1][u-1]=1;  //??£??\????????????ID??§??????"u"???1???????§????????????§?????????????????????u-1??¨?????????
		}	
	}
	for(int i=0;i<N;++i){
		for(int j=0;j<N;++j){
			cout <<G[j][i]<< " ";
		}
		cout<<endl;
	}
}

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

struct Edge {
  int source, target;
  Edge(int source, int target): source(source), target(target) {}
};

struct Node {
  std::vector<Edge> edges;
  void addEdge(Edge edge) {
    edges.push_back(edge);
  }
};

class Graph {
private:
  std::vector<Node> nodes;
  int size;
public:
  Graph(int size): size(size) {
    nodes.resize(size);
  }
  void addEdge(int source, int target) {
    nodes[source].addEdge(Edge(source, target));
  }
  void printAdjacencyList() {
    for(Node node: nodes) {
      std::vector<int> hasEdgeTo(size);
      for(Edge edge: node.edges) {
        hasEdgeTo[edge.target] = 1;
      }
      for(int i = 0; i < size; i++) {
        if(i == size - 1) {
          std::cout << hasEdgeTo[i] << std::endl;
        }else {
          std::cout << hasEdgeTo[i] << ' ';
        }
      }

    }
  }
};

int main() {
  int n;
  std::cin >> n;
  Graph graph(n);
  for(int i = 0; i < n; i++) {
    int u, k;
    std::cin >> u >> k;
    for(int j = 0; j < k; j++) {
      int v;
      std::cin >> v;
      graph.addEdge(u - 1, v - 1);
    }
  }
  graph.printAdjacencyList();
}

C++: #iunclude<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;i<n;j++){
      if(j)cout << " ";
      cout << M[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;
    }

}

C++: #include <iostream>

using namespace std;

#define N_MAX 100

int main()
{
    int n, i, j, u, k, v;
    int Adj[N_MAX][N_MAX] = {};

    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> u >> k;
        while (k-- > 0) {
            cin >> v;
            Adj[u-1][v-1] = 1;
        }
    }

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

    return 0;
}

C++: #include <iostream>

using namespace std;

const int N = 100;

int main() {
	int n;
	cin >> n;
	bool relation[N+1][N+1] = {false};
	
	for (int i=0;i<n;i++) {
		int x,k;
		cin >> x >> k;
		x--;//转换为零起点
		for (int j = 0;j<k;j++) {
			int y;
			cin >> y;
			y--;//转换为零起点
			relation[x][y] = true; 
		}
	}
	
	for (int i= 0;i<n;i++) {
		for (int j = 0;j<n;j++) {
			cout << (short)relation[i][j];
			if (j != n-1) {
				cout << " ";
			} else {
				cout << endl;
			}
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> ans(101,vector<int>(101,0));

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

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

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

int G[110][110];
int n;
int u, k, v;

void Hyoji(int N) {
  for(int i=0; i<N; i++) {
    for(int j=0; j<N; j++) {
      printf("%d", G[i][j]);
      if (j < N-1) {
	printf(" ");
      }
    }
      printf("\n");
  }
}

int main() {
  fill(&G[0][0], &G[0][0]+110*110, 0);
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d%d", &u, &k);
    u--;
    for (int j=0; j<k; j++) {
      scanf("%d", &v);
      v--;
      G[u][v] = 1;
    }
  }
  Hyoji(n);
}