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 <bits/stdc++.h>
using namespace std;

int n;
int k;
int m;

int main() {
  cin >> n;
  int V[n];

  // int型の2次元配列(3×4要素の)の宣言
  vector<vector<int>> A(n, vector<int>(n));

  for (int i=0; i<n; i++) {
    cin >> V[i];
    cin >> k;
    if (k==0) {
      continue;
    } else {
      for (int j =0; j<k; j++) {
        cin >> m;
        A[i][m-1] = 1;
      }
    }
  }

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



 
}

C++: // -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_11_A: Graph

#include <cstdio>
#include <cstring>

int main()
{
  unsigned int n;
  std::scanf("%u", &n);

  int g[n][n];
  std::memset(g, 0, sizeof(g));

  unsigned int u, k, v;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u %u", &u, &k);
    for (auto j = 0u; j < k; ++j) {
      std::scanf("%u", &v);
      g[u-1][v-1] = 1;
    }
  }

  for (auto i = 0u; i < n; ++i) {
    const char* sep = "";
    for (auto j = 0u; j < n; ++j) {
      std::printf("%s%d", sep, g[i][j]);
      sep = " ";
    }
    std::printf("\n");
  }
}

// eof

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

int main()
{
	int M[N][N];  
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			M[i][j] = 0;
		}
	}
	int n,u,k,v;
	cin >> n;
	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 FOR(i,n) for(int i=0;(i)<(n);(i)++)
using namespace std;
int G[101][101] = {};

int main()
{
	int n;
	cin >> n;
	FOR(i, n)
	{
		int m,u;
		cin >> u >> m;
		FOR(j, m)
		{
			int l;
			cin >> l;
			G[u-1][l-1] = 1;
		}
	}
	FOR(i, n)
	{
		FOR(j, n)
		{
			cout << G[i][j];
			if (j != n - 1)cout << " ";
		}
		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<<" "<<flush;
      }
      cout<<M[i][j]<<flush;
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
static const int N = 100;

int main(){
    int n, u, k, v;
    int M[N][N];
    
    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>

int main(void) {
    int n, u, k, v, i, j;
    scanf("%d", &n);
    int m[n+1][n+1];

    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            m[i][j] = 0;

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

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            if (j-1) printf(" ");
            printf("%d", m[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,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>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	vvector<int> ans(n, vector<int>(n, 0));
	rep(i, n){
		int t;
		cin >> t;
		--t;
		int time;
		cin >> time;
		rep(j, time){
			int to;
			cin >> to;
			--to;
			ans[t][to] = 1;
		}
	}

	foreach(i, ans){
		foreach(j, i){
			output(j);
		}
		outendl();
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int graph[105][105];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			graph[i][j]=0;
	}
	for(int i=1;i<=n;i++)
	{
		int v;
		cin>>v;
		int num;
		cin>>num;
		while(num--)
		{
			int aa;
			cin>>aa;
			graph[v-1][aa-1]=1;
			//cout<<v-1<<" "<<aa<<endl;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j>0)
			cout<<" ";
			cout<<graph[i][j];
		}
		cout<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a[101][101]={};
  int n,u,k,v;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      a[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<n;j++)
      cout<<a[i][j]<<' ';
    cout<<a[i][n]<<endl;
  }
  return 0;
}

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

int main(){
   int M[100][100];
   int n;
   cin >> n;

   for(int i=0; i<n; i++)
      for(int j=0; j<n; j++)
         M[i][j]=0;

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

   return 0;
}