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 <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,W;
int vx[]={1,0,-1,0};
int vy[]={0,1,0,-1};
int mt[102][102];
using namespace std;
void solve(){
    cin >> N ;
    int E,K;
    memset (mt,0,102*102);
    REP(i,N){
      cin >> E >> K;
      REP(j,K)
      {
        cin >> E;
        mt[i][E-1] = 1 ;
      }
    }
    REP(x,N){
      REP(y,N){
        cout << mt[x][y] ;
        if(!(x==N-1&&y==N-1))cout << " ";
      }
      if(x!=N-1)cout << endl;
    }
}
int main(){

    solve();
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;


int main(void){
  int n,a,b,c;
  cin >> n;
  int v[n][n];
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<b;j++){
      cin >> c;
      v[a-1][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i][j]!=1)cout << 0 << ' ';
      else cout << v[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

#define NIL NULL
#define INF 1000000001

using namespace std;

int main(){
    int num_node;
    int node_ind,node_deg,adj_node;
    scanf("%d",&num_node);

    vector<vector<int> > adj(num_node,vector<int>(num_node,0));

    for(int i = 0; i < num_node;i++ ){
        scanf("%d %d",&node_ind,&node_deg);
        for(int j = 0;j < node_deg;j++){
            scanf("%d",&adj_node);
            adj[node_ind-1][adj_node-1] = 1;
        }
    }

    for(int i = 0;i < num_node;i++){
        for(int j = 0;j < num_node-1;j++){
            printf("%d ",adj[i][j]);
        }
        printf("%d\n",adj[i][num_node-1]);
    }
    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<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]<<" ";
        }
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <vector <ll>> v(n, vector <ll> (n, 0));
  ll u, k;
  rep(i, n) {
    cin >> u >> k;
    rep(j, k) {
      ll a;
      cin >> a;
      v.at(u-1).at(a-1)++;
    }
  }
  rep(i, n) {
    rep(j, n) {
      if (j) {
        cout << ' ' << v.at(i).at(j);
      } else {
        cout << v.at(i).at(j);
      }
    }
    cout << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n][n];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
        a[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;
      a[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j!=0)cout<<" ";;
      cout<<a[i][j];
    }
    cout<<endl;
  }
}

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

int main(void){
  int m, a[100][100];
  int b[100][100];

  cin >> m;

  for(int i=0; i<m; i++){
    cin >> a[i][0];
    cin >> a[i][1];

    for(int j=2; j<a[i][1]+2; j++){
      cin >> a[i][j];
      b[i][ a[i][j]-1 ] = 1;
    }
  }

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

  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int mat[N][N] = {};

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

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

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

int main()
{
    int n;
    cin >> n;
    bool Adj[n][n] = {};
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            Adj[u - 1][v - 1] = 1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << Adj[i][j];
            if (j != n - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}