Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		arr[u-1] = make([]int, n)
		for j := 0; j < k; j++ {
			n := scanInt()
			arr[u-1][n-1] = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for _, col := range arr {
		fmt.Fprintln(w, strings.Trim(fmt.Sprint(col), "[]"))
	}
	w.Flush()
}

C++: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define find(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

  int n; cin >> n;
  int mat[n][n]; memset(mat, 0, sizeof(mat));

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

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int> > graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(n);
    }
    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++){
        scanf("%d",&u);
        scanf("%d",&k);
        int value;
        for(int j=0;j<k;j++){
            scanf("%d",&value);
            graph[u-1][value-1]=1;
        }
    }

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

    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n,u,k,v;
    cin >> n;
    vector<vector<int>>M(n,vector<int>(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) {
            cout << M[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; //在u和v之间画出一条边
      }
  }
  
  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++: //ALDS1_11A
#include <iostream>
#include <vector>
using namespace std;

int main(){
 int n,u,k,v;
 cin>>n;
 vector< vector<bool> > M(n,vector<bool>(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]=true;
  }
 }

 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>
#include <stdio.h>

#define MAX 100

int main() {
    int n;
    int M[MAX][MAX];
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            M[i][j] = 0;
        }
    }
    
    for (int i = 1; i <= n; i++) {
        int id, k;
        scanf("%d %d", &id, &k);
        if (k == 0) continue;
        else {
            for (int j = 1; j <= k; j++) {
                int v; scanf("%d", &v);
                M[id][v] = 1;
            }
        }
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j == n) printf("%d\n", M[i][j]);
            else printf("%d ", M[i][j]);
        }
    }
    
    return 0;
}

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

class Graph
{
  public:
    Graph(int n);

    void Show() const;

  private:
    vector<vector<int>> m_graph;
};

Graph::Graph(int n) :
  m_graph(n, vector<int>(n, 0))
{
  for (int i = 0; i < n; ++i)
  {
    int u, k;
    cin >> u >> k;
    vector<int> list(k);
    for (int j = 0; j < k; ++j)
    {
      cin >> list[j];
    }

    for (auto v : list)
    {
      m_graph[u-1][v-1] = 1;
    }
  }
}

void Graph::Show() const
{
  for (auto a: m_graph)
  {
    for (auto b : a)
    {
      cout << b << " ";
    }
    cout << endl;
  }
}

int main(void)
{
  int n;
  cin >> n;

  Graph graph(n);
  graph.Show();
  return 0;
}

C++: #include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	ll d[100][100];
	REP(i, n) REP(j, n) d[i][j] = 0;
	REP(i,n)
	{
		cin >> w >> k;
		REP(j, k) {
			cin >> h;
			d[i][h - 1] = 1;
		}
	}
	
	REP(i, n) {
		REP(j, n)
		{
			cout << d[i][j] << ' ';
		}
		cout << endl;
	}
}