Go: package main
import (
	"fmt"
	"bufio"
	"os"
	"bytes"
	"strconv"
	"strings"
)

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num , _ :=  strconv.Atoi(scanner.Text())
	return num
}


func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	N := nextInt(scanner)
	var A [][]int = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = make([]int, N)
	}
	for i:=0; i<N; i++{
		idx := nextInt(scanner)
		cnt := nextInt(scanner)
		for j:=0; j<cnt; j++ {
			node := nextInt(scanner)
			A[idx-1][node-1] = 1
		}
	}
	var outBuffer bytes.Buffer
	for i:=0; i<N; i++ {
		outBuffer.WriteString(strings.TrimRight(fmt.Sprintf("%v",A[i])[1:], "]") + "\n")
	}
	fmt.Printf("%s", outBuffer.String())
}

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

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

return0;
}

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

int main() {
	int n;
	cin >> n;
	int Adj[101][101] = {{0}};
	for (int i = 0;i < n;i++) {
		int th;
		cin >> th;
		int k;
		cin >> k;
		int adj;
		if(k>0)
		for (int j = 0;j < k;j++) {
			cin >> adj;
			Adj[th-1][adj-1] = 1;
		}
	}

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

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

bool A[110][110];

int main (){
	int n,a,b,c;
	cin>>n;
	for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				A[i][j]=false;
		}
	}
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		for(int j=1;j<=b;j++){
			cin>>c;
			A[a][c]=true;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout<<A[i][j]<<(j==n?"\n":" ");
		}
	}
	return 0;
}