Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

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

int main(int argc, char *argv[]) {
    int n;
    scanf("%d", &n);
    int adj_mat[n+1][n+1];

    // init
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            adj_mat[i][j] = 0;
        }
    }

    // read
    for (int i = 1; i <= n; i++) {
        int node_id, adj_num;
        scanf("%d", &node_id);
        scanf("%d", &adj_num);
        for (int j = 1; j <= adj_num; j++) {
            int adj_id;
            scanf("%d", &adj_id);
            adj_mat[node_id][adj_id] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j != n) {
                fprintf(stdout, "%d ", adj_mat[i][j]);
            } else {
                fprintf(stdout, "%d\n", adj_mat[i][j]);
            }
        }
    }

    return 0;
}

C++: #include<iostream>

int main()
{
	int n, u, k, v;
	bool filled[100][100]{};

	std::cin >> n;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> u >> k;
		u--;
		for (int j = 0; j < k; ++j)
		{
			std::cin >> v;
			filled[u][--v] = true;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (j)
				std::cout << " ";
			std::cout << static_cast<int>(filled[i][j]);
		}
		std::cout << std::endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main() {

    int n;
    cin >> n;
    int mat[100][100] = {};
    rep(i, n){
        int k, l;
        cin >> k >> l;
        rep(j, l){
            int v;
            cin >> v;
            mat[k-1][v-1] = 1;
        }
    }

    rep(i, n){
        rep(j, n){
            cout << mat[i][j];
            if(j == n-1){
                cout << "\n";
            }
            else{
                cout << ' ';
            }
        }
    }


    return 0;
}

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

int main(){
    int n; cin >> n;
    int A[n][n];
    
    //初期化
    for (int i=0;i<n;i++){
        for(int j =0;j<n;j++){
            A[i][j] =0;
        }
    }
    
    for(int i = 0;i<n;i++){
        int num,ver;
        cin >> num >> ver;
        for (int j = 0;j< ver;j++){
            int u; cin >> u;
            A[num-1][u-1] =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<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int judge(int i, int n, int variable, vector< vector<int> > &v)
{
	for (int j = 0; j<v[variable].size(); ++j) {
		if (i == v[variable][j]) {
			return 1;
			break;
		}
	}
	return 0;
}
int main()
{
	int n, u, k, vv;
	cin >> n;
	vector< vector<int> > v(n), a(n, vector<int>(n));
	for (int variable = 0; variable<n; ++variable) {
		cin >> u >> k;
		for (int i = 0; i<k; ++i) {
			cin >> vv;
			v[variable].push_back(vv);
		}
	}
	for (int variable = 0; variable<n; ++variable)
		for (int i = 1; i <= n; ++i)
			a[variable][i - 1] = judge(i, n, variable, v);
	for (int variable = 0; variable<n; ++variable)
		for (int i = 0; i<n; ++i)
			printf("%d%c", a[variable][i], i == n - 1 ? '\n' : ' ');
}

C++: #include <stdio.h>
#include <string.h>

int main(){
  int Adj[101][101],n,v,i,j,u,k;
  memset(Adj, 0, 101*101*sizeof(int));
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1)printf(" ");
      printf("%d",Adj[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

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

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++: #define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	int g[100][100];
	int n;
	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 > 0) {
				cout << " ";
			}
			cout << g[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;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
static const int N=100;

int main(){
  int m[N][N],n,u,k,v,i,j;

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

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

C++: //
#if 0

#endif // 0
#include<iostream>
#define MAX 100
using namespace std;
int matri[MAX][MAX];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            matri[i][j]=0;
    for(int i=0;i<n;i++)
    {
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            int m;
            cin>>m;
            matri[u-1][m-1]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        int j;
        for(j=0;j<n-1;j++)
            cout<<matri[i][j]<<" ";
        cout<<matri[i][j]<<endl;
    }
    return 0;
}

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

int main(){
	int n,m,l,i,j,p;
	cin >> n;
	int f[100][100];
	for ( i = 0; i < n; i++){
		cin >> m;
		cin >> p;
		for ( j = 0; j < p; j++){
			cin >> l;
			f[m-1][l-1] = 1;
		}
	}
	for ( i = 0; i < n; i++){
		for ( j = 0; j < n-1; j++){
			cout << f[i][j] << " ";
		}
		cout << f[i][n-1] << endl;
	}
}

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

#define REP(i,n) for(int i=0;i<n;++i)

const int MAX_N = 100;

int main() {
  int n, u, k, v, G[MAX_N][MAX_N] = {0};
  cin >> n;
  REP(i, n) {
    cin >> u >> k;
    REP(j, k) {
      cin >> v;
      G[u - 1][v - 1] = 1;
    }
  }
  REP(i, n) {
    REP(j, n) {
    if(j) cout << ' ';
    cout << G[i][j];
    }
    cout << endl;
  }
  return 0;
}