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;

int ari;
int jigoku[102];
int u[102];
int v[102][102];
int ushi[102][102];
int main(){
  cin>>ari;
  for(int i=1;i<ari+1;i++){
    cin>>u[i]>>jigoku[u[i]];
      for(int j=1;j<jigoku[u[i]]+1;j++){
	cin>>v[u[i]][j];
      }
  }
  //for(int uma=1;uma<ari+1;uma++){cout<<u[uma];}
  for(int k=1;k<ari+1;k++){
    for(int l=1;l<jigoku[k]+1;l++){
      for(int m=1;m<ari+1;m++){
	//cout<<v[k][l];
	if(v[k][l]==u[m]){ushi[k][m]=1;}
	//cout<<ushi[k][m];
      }
    }
  }
    for(int k=1;k<ari+1;k++){
      for(int m=1;m<ari+1;m++){
	cout<<ushi[k][m];}
      cout<<endl;}
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int> > a(n, vector<int>(n, 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-1; j++) {
            cout << a[i][j] << " ";
        }
        cout << a[i][n-1] << endl;
    }
}

C++: //
// Created by 李青坪 on 2018/10/31.
//

#include <cstdio>
#include <algorithm>

#define MAXN 101
using namespace std;

int graph[MAXN][MAXN];

void init(){
    for (auto &i : graph) {
        fill(i, i +MAXN, 0);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    init();
    int v, dgr;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v, &dgr);
        int node;
        for (int j = 0; j < dgr; ++j) {
            scanf("%d", &node);
            graph[v][node] = 1;
        }
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            if (i-1) printf(" ");
            printf("%d", graph[k][i]);
        }
        printf("\n");
    }
}
/*
4
1 2 2 4
2 1 4
3 0
4 1 3

 */

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
static const int N = 100;

int main() {
	int a[N][N];
	int n, u, k, v;
	cin >> n;

	rep(i, n) rep(j, n) a[i][j] = 0;

	rep(i, n) {
		cin >> u >> k;
		u--;
		rep(j, k) {
			cin >> v;
			v--;
			a[u][v]++;
		}
	}


	rep(i, n){
		rep(j, n) {
			if (j) cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <sstream>

using namespace std;

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

  int A[n + 1][n + 1];
  for (auto row : A) {
    fill(row, row + n + 1, 0);
  }

  for (string line; getline(cin, line);) {
    istringstream is{line};
    int i, j;
    is >> i;
    int k;
    is >> k; // # of neighbors; don't use
    while (is >> j)
      A[i][j] = 1;
  }

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

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
vector<int> adj[100];
int res[100][100] = {0};

int main() {
    int n; cin >> n;
    REP(i, n){
        int u, k;
        cin >> u >> k;
        REP(j, k) {
            int tmp;
            cin >> tmp;
            res[u][tmp] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n ; j++)
            cout << res[i][j] << " ";
        cout << res[i][n] << endl;
    }
    return 0;
}

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

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

C++: #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int e[105][105];
int main()
{
    int n;
    int k,m,p;
    memset(e,0,sizeof(e));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&k);
        scanf("%d",&m);
        for(int j=1;j<=m;j++)
        {
            scanf("%d",&p);
            e[k][p] = 1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j != n)
                printf("%d ",e[i][j]);
            else
                printf("%d",e[i][j]);
        }

        printf("\n");
    }
    return 0;

}

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

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

    for (int i = 0; i < n; ++i) {
        int v, k;
        cin >> v >> k;
        for (int j = 0; j < k; ++j) {
            int s;
            cin >> s;
            M[v][s] = 1;
        }
    }

    for (int l = 1; l <= n; ++l) {
        for (int i = 1; i <= n; ++i) {
            cout << M[l][i];
            if (l != n && i != n) cout << " ";
        }
        if (l != n)
        cout << endl;
    }

    return 0;
}

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

#define 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<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int mat[101][101];

int main(int argc,char* argv[]){
  memset(mat,0,sizeof(mat));
  int n,v,cnt,x;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>v>>cnt;
    for(int j=0;j<cnt;j++){
      cin>>x;
      mat[v][x]=1;
    }
  }

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

      if(j!=n)
	cout<<" ";
    }
    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));
    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";
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

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

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