Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

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

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

int main(){
  int n,u,k[100],ar[100][100],i;
  int l,s;
  cin>>n;
  int j;
  for(i=0;i<n;i++){
    cin>>u>>k[i];
    for(j=0;j<k[i];j++){
      cin>>ar[u][j];
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      l=0;
      for(s=0;s<k[i-1];s++){
	if(j==ar[i][s]){
	  cout<<"1";
	  l=1;
	  break;
	}
      }       
      if(l==0)cout<<"0";
      if(j<n)cout<<" ";
    }
    cout<<endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
bool m[110][110];
int main()
{
    int n,u,k,v;
    cin>>n;
    for(int j=1;j<=n;j++)
    {
        cin>>u>>k;
        for(int i=1;i<=k;i++)
        {
            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++: #include <iostream>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j];
            if(j != n-1)
            cout << " ";
        }
        cout << endl;
    }
}

C++: #include<cstdio>
#define MAX 100
int A[MAX][MAX] = {0};

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

	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			if(j) printf(" ");
			printf("%d", A[i][j]);
		}
		printf("\n");
	}

	return 0;

}

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

int main(){
int M[N][N];
int n,u,v,k;

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


static const int MAX_NUM = 100 + 1;

int main(void)
{
    int i, j;
    int num;
    int elem;
    int elemnum;
    int tmp;
    int matrix[MAX_NUM][MAX_NUM] = {0};


    scanf("%d", &num);
    for (i = 1; i <= num; i++) {
        scanf("%d %d", &elem, &elemnum);
        for (j = 1; j <= elemnum; j++) {
            scanf("%d", &tmp);
            matrix[elem][tmp] = 1;
        }
    }

    for (i = 1; i <= num; i++) {
        for (j = 1; j <= num; j++) {
            printf(" %d", matrix[i][j]);
        }
        printf("\n");
    }

    return 0;
}