Go: package main
import (
	"fmt"
	"bufio"
	"os"
	"bytes"
	"strconv"
	"strings"
)

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num , _ :=  strconv.Atoi(scanner.Text())
	return num
}


func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	N := nextInt(scanner)
	var A [][]int = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = make([]int, N)
	}
	for i:=0; i<N; i++{
		idx := nextInt(scanner)
		cnt := nextInt(scanner)
		for j:=0; j<cnt; j++ {
			node := nextInt(scanner)
			A[idx-1][node-1] = 1
		}
	}
	var outBuffer bytes.Buffer
	for i:=0; i<N; i++ {
		outBuffer.WriteString(strings.TrimRight(fmt.Sprintf("%v",A[i])[1:], "]") + "\n")
	}
	fmt.Printf("%s", outBuffer.String())
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846



int main(){
	int n,i,j,k,u,v;
	cin>>n;
	vii a(n,vi(n,0));
	loop(i,0,n){
		cin>>u>>k;
		loop(j,0,k){
			cin>>v;
			a[u-1][v-1]=1;
		}
	}
	loop(i,0,n){
		loop(j,0,n){
			cout<<a[i][j];
			if(j!=n-1){
				cout<<" ";
			}else{
				cout<<endl;
			}
		}
	}
}

C++: #include <iostream>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;
  int M[105][105] = {};

  rep(i, n) {
    int u, k; cin >> u >> k;
    // 0-origin
    --u;
    rep(j, k) {
      int v; cin >> v;
      // 0-origin
      --v;
      M[u][v] = 1;
    }
  }
  rep(i, n) rep(j, n) {
    cout << M[i][j] << (j==n-1 ? '\n' : ' ');
  }
}

C++: //16D8103012G 三品海渡
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 2; j < n; j++)
	{
	  if (ln[i][j] != 0 && m[j][i]==0)
	    {
	      m[i][ln[i][j]-1] = 1;
	    }
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
	{
	  cout << m[i][j] << " ";
	}
      cout << endl;
    }
  return 0;
}

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

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

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

int x[30000][30000],n,q,r,b;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> q >> r;
		for (int j = 0; j < r; j++) {
			cin >> b;
			x[i][b] == true;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) { cout << ' '; }
			cout << x[i][j+1];
		}
		cout << endl;
	}
	return 0;
}

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

int n;
int ad_list[101][101];

void print(){
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            cout << ad_list[i][j];
            if(j==n)cout << "\n";
            else cout << " ";
        }
    }
}

int main(){
    cin  >> n;
    for(int i=1;i<n+1; i++){
        for(int j=1; j<n+1; j++){
            ad_list[i][j]=0;
        }
    }
    int v,k, in;
    for(int i=1; i<n+1; i++){
        cin >> v >> k;
        for (int j=0;j<k;j++){
            cin >> in;
            ad_list[v][in]=1;
        }
    }
    print();
}

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;
const int MAXN = 100+7;
struct node{
    int id;
    struct node* next;
};
struct node* graph[MAXN];
int matrix[MAXN][MAXN];
int main() {
    int n;
    scanf("%d", &n);
    int i;
    for(i = 1; i <= n; i++){
        graph[i] = (node*)malloc(sizeof(node));
        graph[i]->next = NULL;
    }
    memset(matrix, 0, sizeof(matrix));
    for(i = 0; i < n; i++){
        int pnum;
        int k;
        scanf("%d", &pnum);
        scanf("%d", &k);

        int j;
        for(j = 0; j < k; j++){
            int r;
            scanf("%d", &r);
            node* newp = (node*)malloc(sizeof(node));
            newp->id = r;
            newp->next = NULL;
            node* p = graph[pnum];
            while(p->next!=NULL){
                p = p ->next;
            }
            p->next = newp;
        }
    }
    for(i = 1; i <= n; i++){
        struct node* p = graph[i]->next;
        while(p!=NULL){
            matrix[i][p->id] = 1;
            p = p->next;
        }
    }
    for(i = 1; i <= n; i++){
        int j;
        for(j = 1; j <= n; j++){
            if(j!=1) printf(" ");
            printf("%d", matrix[i][j]);
        }
        printf("\n");
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n;
  cin >> n;
  vector< vector<int> > g(n, vector<int>(n));
  int u, k;
  for(int i=0; i<n; i++){
    cin >> u >> k;
    int v;
    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 != n-1 ) cout << g[i][j] << " ";
      else cout << g[i][j] << endl;
    }
  }

  return 0;
}

// EOF

C++: #include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;;
using vvi=vector<vi>;
using vb=vector<bool>;
using pii=pair<int,int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vector<vb> matr(n,vb(n,false));
    rep(i,0,n){
        int index;
        cin>>index;
        index--;
        int num,in;
        cin>>num;
        rep(c,0,num){
            cin>>in;
            in--;
            matr[index][in]=true;
        }
    }
    rep(i,0,n){
        int cnt=0;
        rep(j,0,n){
            if(cnt++)cout<<" ";
            cout<<matr[i][j];
        }
        cout<<endl;
    }
    return 0;
}