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<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define vec vector
#define vll vec<ll>
#define dou(s) atof(s.c_str())
#define lon(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define line "\n"
#define mav(a) (*max_element(ALL(a)))
#define miv(a) (*min_element(ALL(a)))
#define vfind(a,n) (find(ALL(a),n)-a.begin())
#define prque priority_queue
#define MOD 1000000007ll
using namespace std;
void solve();
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

//nCk(mod p)
/*ll fac[510000], finv[510000], inv[510000];
void cmodf(ll p = MOD) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, 510000) {
		fac[i] = fac[i - 1] * i%p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		finv[i] = finv[i - 1] * inv[i] % p;
	}
}
ll cmod(ll n, ll k, ll p = MOD) {
	return fac[n] * (finv[k] * finv[n - k] % p) % p;
}*/

//最大公約数
ll gcd(ll n, ll m) {
	ll k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return m;
}
ll gcd(vector<ll> a) {
	rep(i, 1, a.size()) {
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
	}
	return a.back();
}

//最小公倍数
ll lcm(ll n, ll m) {
	ll t = n * m, k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return t / m;
}
ll lcm(vector<ll> a) {
	ll n;
	rep(i, 1, a.size()) {
		n = a[i - 1] * a[i];
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
		n /= a[i];
		a[i] = n;
	}
	return n;
}

//keyの小さい方から探していった時に初めてvalueがjoken以上になる時のkey（keyが増えたらvalueも増えるか同じになるとき）
ll value(ll key) {
	/*変更*/
	return 0;
}
ll mini(ll lkey, ll rkey/*ここも調べる*/, ll joken) {
	ll mkey;
	while (lkey != rkey) {
		mkey = (lkey + rkey) / 2;
		if (value(mkey) >= joken)rkey = mkey;
		else lkey = mkey + 1;
	}
	return rkey;
}

//ペア配列の整理
struct cpl {
	ll f, s;
	bool operator<(const cpl &c) const {
		return f != c.f ? f < c.f : s < c.s;
	};
};

//変数定義

//再帰関数

//アルゴリズム
void solve() {
	ll k, m, n; cin >> n;
	rep(i, 0, n) {
		cin >> k >> m;
		vll a(n, 0);
		rep(j, 0, m) {
			cin >> k;
			a[k - 1] = 1;
		}
		cout << a[0];
		rep(j, 1, n) {
			cout << " " << a[j];
		}
		cout << line;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

int main(){
  int graph[101][101];
  int vol_size;
  int vol, deg, v;
  cin >> vol_size;
  // init
  rep(i,vol_size + 1){
    rep(j,vol_size + 1){
      graph[i][j] = 0;
    }
  }

  rep(i,vol_size){
    cin >> vol >> deg;
      rep(j,deg){
        cin >> v;
        graph[vol][v] = 1;
      } 
  }

  for(int i = 1; i <= vol_size; i++){
    for(int j = 1; j<= vol_size; j++){
      if(j > 1) cout << " ";
      cout << graph[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

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

	return 0;
}

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

int main()
{
	int n, u, k, v[101], VM[101][101];
	memset(VM, 0, sizeof(VM));
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> u >> k;

		for (int j = 1; j <= k; j++)
		{
			cin >> v[j];
			VM[u][v[j]] = 1;
		}
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j < n; j++)
			cout << VM[i][j] << " ";

		cout << VM[i][n] << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int G[100][100];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		int u, k; cin >> u >> k;
		--u;
		while (k--) {
			int v; cin >> v;
			G[u][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;
	}

	return 0;
}

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

int main() {
    int n, idx, g_num, a;
    int G[MAX+1][MAX+1];

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> idx >> g_num;
        for(int j=0; j<=n; j++) {
            G[idx][j] = 0;
        }
        for(int j=0; j<g_num; j++) {
            cin >> a;
            G[idx][a] = 1;
        }   
    }

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

    return 0;
}

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

int main() {

	int n;
	std::cin >> n;

	std::vector<std::vector<int>> g(n,std::vector<int>(n,0));

	for (int i{}; i < n; ++i) {
		int u, k;
		std::cin >> u >> k;
		for (int ki{}; ki < k; ++ki) {
			int vi;
			std::cin >> vi;
			g[u - 1][vi - 1] = 1;
		}
	}

	if(n>1)
	for (const auto&e : g) {
		std::copy(
			std::begin(e)
			, std::prev(std::end(e))
			, std::ostream_iterator< const std::decay_t<decltype(e)>::value_type &>{std::cout, " "}
		);
		std::cout << *( std::end(e)-1 ) << "\n";
	}
	else
		for (const auto&e : g) {
			for (const auto&ee : e)
				std::cout << ee << "\n";
		}

	return 0;
}