Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	for i := 0; i < num; i++ {
		sc.Scan()
		sc.Text()
		sc.Scan()
		num2, _ := strconv.Atoi(sc.Text())
		r := make([]int, num)
		for j := 0; j < num2; j++ {
			sc.Scan()
			val, _ := strconv.Atoi(sc.Text())
			r[val-1] = 1
		}
		for i, v := range r {
			if i != 0 {
				fmt.Printf(" %v", v)
			} else {
				fmt.Printf("%v", v)
			}
		}
		fmt.Println()
	}
}

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

using namespace std;

int main(void)
{
    int n, u, k, v;
    cin >> n;
    vector<vector<int>> vec(n, vector<int>(n));
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            vec[u-1][v-1] = 1;
        }
    }
    
    for (auto& i : vec) {
        int cnt = 0;
        for (auto& j : i) {
            cout << j;
            cnt++;
            if (cnt != n) cout << " ";
        }
        cout << endl;
    }
}

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

int main(){
    int M[N][N];//0 0 起点的邻接矩阵
    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--;//转换为0零起点
        for(int j=0; j<k; j++){
            cin >> v;
            v--;//转换为零起点
            M[u][v] = 1;//在顶点u和顶点v之间画出一条边
        }
    }

    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 <cstdio>
using namespace std;
#define MAX_N (105)
bool G[MAX_N][MAX_N];
int main()
{
    int n;
    scanf("%d", &n);
    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);
	    G[u-1][v-1] = true;
	}
    }

    for ( int i = 0; i < n; i++ ) {
	for ( int j = 0; j < n; j++ ) {
	    printf("%d%c", (int)G[i][j], (j == n - 1) ? '\n' : ' ');
	}
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int M[101][101];

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 <iostream>

using namespace std;

int main(int argc, char** argv)
{
	// Input
	int adj_m[100][100] = { 0 };
	int n;
	cin >> n;
	int u,v,k;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			adj_m[u - 1][v - 1] = 1;
		}
	}

	// Output
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			cout << " " << adj_m[i][j];
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100]={},v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i] >> k[i];

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<n; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=n)
        cout << " ";
      }

      cout << endl;
    }
  }

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

int main(){
	int n, u, k, v;
	int Graph[100][100] = {};
	
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		cin >> u >> k; //u = ??????????????? k = u?????????????¬???°
		u--;
		for(int j = 0 ; j < k ; j++){
			cin >> v; //v = ??£??\?????????????????????
			v--;
			Graph[u][v] = 1;
		}
	}
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			if(j != 0){
				cout << " ";
				}
			cout << Graph[i][j];
			}
		cout << endl;
		}
	
	return 0;
}

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

int a[100][100];
int N,u,k,col;
int main() {
	cin >> N;
	for(int i=0; i<N; ++i) {
		cin >> u >> k;
		for(int l=0; l<k; ++l) {
			cin >> col;
			a[u-1][col-1] = 1;
		}
		cout << a[i][0];
		for(int l=1; l<N; ++l) {
			cout << " " << a[i][l];
		}
		cout << endl;
	}
}

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

int main(){
    int n, u, k, v;
    cin >> n;
    bool a[n + 1][n + 1] = {0};
    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 << a[i][j];
            if(j != n)
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
  int n,u,k,v;
  int G[100][100]={};

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

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

using namespace std;
typedef pair<int,int> p;

int main(void){
  int n,a,b,c;
  cin >> n;
  int v[n][n];
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<b;j++){
      cin >> c;
      v[a-1][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i][j]!=1)cout << 0;
      else cout << v[i][j];
      if(j!=n-1)cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: # include <iostream>
# include <cstring>
# include <cstdio>
using namespace std;
int main(void)
{
	int a[105][105];
    int n,cnt,u,k;
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    for(int w = 0;w < n;w++)
    {
    	scanf("%d %d",&u,&cnt);
    	for(int i = 0;i < cnt;i++)
    	{
    		scanf("%d",&k);
    		a[u][k] = 1;
		}
	}
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++) cout<<a[i][j]<<(j == n?"\n":" ");
	return 0;
}

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

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

    for (int y = 0; y < n; y++) {
        int num, k;
        cin >> num >> k;
        for (int i = 0; i < k; i++) {
            int x;
            cin >> x;
            x--;
            G[x][y] = 1;
        }
    }

    for (int y = 0; y < n; y++) {
        cout << G[0][y];
        for (int x = 1; x < n; x++) {
            cout << " " << G[x][y];
        }
        cout << endl;
    }

    return 0;
}