Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vint;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)

int main(){
    int n;
    cin >> n;
    vector<vint> A(n,vint(n,0));
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v;
            cin >> v;
            A[u-1][v-1]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout << A[i][j];
            if(j<n-1) cout << ' ';
        }
        cout << endl;
    }
}

C++: #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[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<cstdio>
#include<iostream>
using namespace std;
int H[110][110];
int main()
{
    int n,m,a,b;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        scanf("%d",&a);
        for(int i=0;i<a;i++)
        {
            scanf("%d",&b);
            H[m][b]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        printf("%d ",H[i][j]);
        printf("\n");
    }
    return 0;
}

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

int ari;
int jiku[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];
    cin>>jiku[u[i]];
      for(int j=1;j<jiku[u[i]]+1;j++){
	cin>>v[u[i]][j];
      }
  }
  for(int k=1;k<ari+1;k++){
  //	cout << jiku[k] << endl;
    for(int l=1;l<jiku[k]+1;l++){
    //	cout << k << " " << l << endl;
      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;m++){
	cout<<ushi[k][m]<<" ";
      }cout<<ushi[k][ari];
      cout<<endl;}
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<vector<int> > mat(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    int u = -1, k = -1, v = -1;
    fscanf(stdin, "%d %d", &u, &k);
    for (int j = 0; j < k; ++j) {
      fscanf(stdin, "%d", &v);
      mat[u - 1][v - 1] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j) { fprintf(stdout, " "); }
      fprintf(stdout, "%d", mat[i][j]);
    }
    fprintf(stdout, "\n");
  }
  return 0;
}

C++: #include<iostream>

using namespace std;
 
int main()
{
  int g[100][100];
  int n;
  
  for(int i=0; i<100; i++)
    {
      for(int j=0; j<100; j++)
	{
	  g[i][j]=0;
        }
    }
  
  cin>>n;

  int x,y,z;
    
  for(int i=0; i<n; i++)
    {
      cin>>x>>y;
      for(int j=0; j<y; j++)
	{
	  cin>>z;
	  g[x-1][z-1]=1;
        }
    }
  
  for(int i=0; i<n; i++)
    {
      for(int j=0; j<n; j++)
	{
	  if(j!=0) cout<<" ";
	  cout<<g[i][j];
        }
      cout<<'\n';
    }
    return 0;
}

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

int main()
{
    int n,u,v,d;
    int G[101][101];
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            G[i][j]=0;
    for(int i=0;i<n;i++)
    {
        cin>>u>>d;
        for(int k=0;k<d;k++)
        {
            cin>>v;
            G[u][v]=1;
            //cout<<u<<' '<<v<<' '<<G[u][v]<<endl;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int isn=0;
        for(int j=1;j<=n;j++)
        {
            if(isn++>0)cout<<' ';
            cout<<G[i][j];
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int adj[100][100] = {0};
int main()
{
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		int j, k;
		cin >> j >> k;
		j--;
		for (int m=0;m<k;m++) {
			int a;
			cin >> a;
			a--;
			adj[j][a]=1;
		}
	}

	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			cout << adj[i][j];
			if (j<n) cout << ' ';
		}
		cout << endl;
	}
		
	return 0;
}

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

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

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

int main() {
	
	int i, j, n, u, k, v, maxu, a[102][102] = {};
	
	cin >> n;
	maxu = 0;
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		for (j = 0; j < k; j++) {
			cin >> v;
			a[u][v] = 1;
			maxu = max(maxu, u);
		}
	}

	for (i = 1; i <= maxu; i++) {
		for (j = 1; j <= maxu; j++) {
			cout << " " << a[i][j];
		}
		cout << endl;
	}
}

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

static const int N=100;

int main()
{
    int M[100][100];
    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;
}