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

int main(){

  int N,u,k,v;
  cin>>N;
  int graph[N][N];

  //init
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      graph[i][j]=0;

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

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout<<graph[i][j];
      if(j==N-1) cout<<endl;
      else cout<<" ";
    }
  }
  return 0;
}

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-1;++j){
			cout <<G[j][i]<< " ";
		}
		cout<< G[N-1][i]<<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


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--;
		rep(j, k)
		{
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	
	rep(i, n)
	{
		rep(j, n)
		{
			if (j) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

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

C++: #include<iostream>
using namespace std;
static const int N=100;
int M[N+1][N+1];
int main(){
    int n,u,k,v;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>u>>k;
        for(int j=1;j<=k;j++){
            cin>>v;
            M[u][v]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)
            cout<<(j>1?" ":"")<<M[i][j];
        cout<<"\n";
    }
    return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  
 //とても大きい値を無限としておく。
  int n;
  cin >> n;  //Vは与えられた頂点数,Eは辺の数
  vector<vector<int>> a(n,vector<int>(n,0));//V*Vを無限で初期化
  for(int i=0;i<n;++i){
    int u,k;
    cin>>u>>k;
    u--;
    for(int j=0;j<k;++j){
      int v;
      cin>>v;
      v--;
      a[u][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 <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<vector<ll>> edge(N, vector<ll>(N, 0));
    REP(_, N) {
        ll n, k;
        cin >> n >> k;
        n--;
        REP(__, k) {
            ll v;
            cin >> v;
            v--;
            edge[n][v]++;
        }
    }

    REP(i, N) {
        REP(j, N) {
            cout << edge[i][j];
            if (j < N - 1)
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}

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

bool c[128][128];

int main(void) {

  int n;
  int u;
  int k;
  int v;

  std::cin >> n;
  for(int i = 1; i <= n; ++i) {
    std::cin >> u >> k;
    for(int j = 1; j <= k; ++j) {
      std::cin >> v;
      c[u][v] = true;
    }
  }

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

  return 0;
}

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

int n;
vector<vector<int> > g;
int ans[101][101];

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

C++: #include<iostream>
#define SIZE 100

using namespace std;

int main(void) {

	int n, c, v;
	int G[SIZE][SIZE];
	int A[SIZE][SIZE];

	cin >> 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++) {
		cin >> v;
		cin >> c;
		for (int j = 0; j < c; j++) {
			cin >> G[v-1][j];
			int tmp = G[v-1][j];
			if (tmp > 0) {
				A[v-1][tmp - 1] = 1;
			}
		}
	}

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