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 <iostream>
using namespace std;
static const int N=100;

int main(){
    //0 0 ??????????????\??????
    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;
        //??¬??¢???0??????
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            //??¬??¢???0??????
            v--;
            //??¨u???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;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<int>> edge(110);
    int n; cin>>n;
    for(int i=0; i<n; i++)
    {
        int u; cin>>u;
        u--;
        int k; cin>>k;
        if(k!=0) {
        for(int j=0; j<k; j++){
            int v; cin>>v;
            v--;
            edge[u].push_back(v);
        }
    }
    }
    for(int i=0; i<n; i++){
        vector<int> ans(n,0);
        for(int j=0; j<edge[i].size(); j++){
            ans[edge[i][j]]++;
        }
        for(int k=0; k<n; k++){
            cout<<ans[k]<<(k==n-1?'\n':' ');
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n"<<endl;
    }
    
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int x[101][101];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			x[i][j] = 0;
		}
	}
	int u, k, v;
	for (int i = 0;i < n;i++) {
		cin >> u >> k;
		u = u - 1;
		for (int j = 0;j < k;j++) {
			cin >> v;
			v = v - 1;
			x[u][v] = 1;
		}
	}

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

	return 0;
}

C++: 
#include<iostream>

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<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 <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]) {
    int n, u, k, v;
    cin >> n;
    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;
            G[i][v-1] = 1;
        }
    }

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

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

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

int main (){
    int M[N][N] = {0};
    int n,u,k,v;
    cin >> n;

    for (int i = 0; i < n ; ++i) {
     cin >> u >> k;
        u--; //0?????????????????????
        for (int j = 0; j < k ; ++j) {
            cin >> v;
            v -- ; // 0?????????????????????
            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++: //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>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define MAX 100000

int main(){
  int n;
  cin >>n;
  int A[n+2][n+2]={0};
  int t,k,l;
  for(int i=1;i<=n;i++){
    cin >> t >> k;
    for(int j=1;j<=k;j++){
      cin >> l;
      A[i][l]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(j) cout << " ";
      cout << A[i][j];
    }
    cout << endl;
  }
  return 0;
}