Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

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

using namespace std;
#define MAX 100
int N[MAX][MAX];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            N[i][j] = 0;
        }
    }
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            N[i][v-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j!=0) cout<<" ";
            cout<<N[i][j];
        }
        cout<<endl;
    }
    return 0;
}

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

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;


int main(){

  int n;
  int G[105][105];

  cin >> 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){
    int u,k,v;
    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; ++j){
      if(j) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }

}

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<iostream>
#define rep(i, n) for (int i=0; i<(n); i++)
using namespace std;

static const int N=100;

int main() {
  int M[N][N];
  int n,u,k,v;
  cin>>n;
  rep(i, n) {
    rep(j, n) {
      M[i][j]=0;
    }
  }
  rep(i, n) {
    cin>>u>>k;
    u--; //0オリジンへ変換
    rep(j, k) {
      cin>>v;
      v--; //0オリジンへ変換
      M[u][v]=1;//uとvの辺を張る
    }
  }

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

  return 0;
}

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

using namespace std;

int main() {
    size_t n;
    scanf("%zu", &n);

    for (size_t i=0; i<n; ++i) {
        size_t k;
        scanf("%*d %zu", &k);

        vector<int> v(n+1);
        for (size_t j=0; j<k; ++j) {
            size_t d;
            scanf("%zu", &d);

            v[d] = 1;
        }

        for (size_t j=1; j<=n; ++j)
            printf("%d%c", v[j], j<n? ' ':'\n');
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,k,u,v;
	bool 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;j++){
			cout<<G[i][j];
			if(j<n-1)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
  int n,u,k,b[120][120],a;
  cin>>n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      b[i][j]=0;   
    }
  }
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>a;
      b[u][a]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout<<b[i][j];
      if(j<n)cout<<" ";
    }
    cout<<endl;
  }

  return 0;
}

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

int main() {
  int M[N][N];  // 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--;  // 0 オリジンへ変換
      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++: #define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

typedef pair<long long int, long long int> P;

long long int DP[1001][1001] = {};

int main(){
	
	int n;
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		
		int id, k;
		cin >> id >> k;
		id--;
		
		for(int i = 0; i < k; i++){
			int num;
			cin >> num;
			num--;
			DP[id][num] = 1;
		}
		
	}
	
	for(int i = 0; i < n; i++){
		cout << DP[i][0];
		for(int j = 1; j < n; j++){
			cout << " " << DP[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include <iostream>

constexpr int MAXN = 100;
int V[MAXN][MAXN];
int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int id, e_num;
        std::cin >> id >> e_num;
        for (int j = 0; j < e_num; j++) {
            int t;
            std::cin >> t;
            V[id - 1][t - 1] = 1;
        }
    }

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

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

using namespace std;

const int N_MAX = 100;

// グラフ
// 隣接リスト表現の有効グラフGの隣接行列を出力

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cout << "hello world" << endl;

    int n;
    cin >> n;

    int G[100][100] = { 0 };

    for (int i = 0; i< n; i++)
    {
        int u, k;
        cin >> u; // 頂点番号
        cin >> k; // 出次数
        for (int i = 0; i < k; i++)
        {
            int v;
            cin >> v;
            G[u-1][v-1] = 1;
        }
    }

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

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

struct noo{
  int yoko;
  int tate;
  int nn[];
};

noo t[1000000];
int n;
int k;


int main(){
  int adj[n+10][n+10];
  int num;
  cin>>n;
  int rin[n+1];
  int i=0,j=0;
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    cin>>num>>k;
    for(j=0;j<k;j++){
      cin>>rin[j];
      adj[num][rin[j]]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j)cout<<" ";
      cout<<adj[i][j];
    }
    cout<<endl;
  }
  return 0;
}