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++: //
// Created by tattsun on 2017/02/11.
//

#include <iostream>
#include <vector>
using namespace std;

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

    int u, k, p;
    for(int i=0; i<n; i++) {
        cin >> u >> k;

        vector<int> dest;
        for(int j=0; j<k; j++) {
            cin >> p;
            dest.push_back(p);
        }

        vector<int>::iterator it = dest.begin();
        for(int j=0; j<n; j++) {
            if(j != 0) cout << " ";
            if(it != dest.end() && j == *it-1) {
                cout << "1";
                it++;
            } else {
                cout << "0";
            }
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

//??\???????????????
//4
//1 2 2 4
//2 1 4
//3 0
//4 1 3

bool Path[101][101] = {false};

int main(){
    int  N;
    cin >> N;
    int bb;
    for (int i = 1; i <= N; i++) {
        int K;
        scanf("%d %d",&bb,&K);
        for (int k = 0; k < K; k++) {
            int p;
            scanf("%d",&p);
            
            Path[i][p] = true;
        }
    }
    
    for (int r = 1; r <= N; r++) {
        for (int c = 1; c <= N; c++) {
            printf("%d ",Path[r][c]);
        }
        printf("\n");
    }
    return 0;
}

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

int main() {
	int n, u, k, x;
	int matrix[101][101] = {};

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> x;
			matrix[u][x] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << matrix[i][j] << " " ;
		}
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int g[101][101];
int main(void){
  int n;
  cin>>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;
      g[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout<<g[i][j]<<" \n"[j==n];
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
static const int MAX  = 100;
int main ()
{
  int n,u,k,v;
  cin>>n;
  int M[MAX][MAX];
  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<<" ";
         else cout<<M[i][j];
     }
     cout<<endl;
   }
  return 0 ;
}

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

#define N_MAX 100

int main() {
    long n, v, deg_out, e;
    cin >> n;

    long G[N_MAX][N_MAX] = {};

    for (long i = 0; i < n; i++) {
        cin >> v >> deg_out;
        for (long j = 0; j < deg_out; j++) {
            cin >> e;
            G[v - 1][e - 1] = 1;
        }
    }

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

    return 0;
}

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

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

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

int a[MAXN][MAXN];

int main(void)
{
    int n,u,v,t;
    cin>>n;
    for(int i = 1; i <= n; ++i)
    {
        cin>>u>>t;
        for(int j = 1; j <= t; ++j)
        {
            cin>>v;
            a[u][v] = 1;
        }
    }
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j < n; ++j)
        {
            cout<<a[i][j]<<' ';
        }
        cout<<a[i][n]<<'\n';
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> adjlist;
vector<vector<int>> adjmatrix;
void input(int n){
  for(int i=0;i<n;i++){
    vector<int> list;
    int ln;
    cin>>ln;
    list.push_back(ln);
    cin>>ln;
    list.push_back(ln);
    for(int j=0;j<ln;j++){
      int an;
      cin>>an;
      list.push_back(an);
    }
    adjlist.push_back(list);
  }
}

void mk_am(int n){
  adjmatrix=vector<vector<int>>(n,vector<int>(n,0));
  for(vector<int> list:adjlist){
    for(int i=0;i<list[1];i++){
      adjmatrix[list[0]-1][list[2+i]-1]=1;
    }
  }
}
 
void print(int n){
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<adjmatrix[i][j];
      if(j!=n-1) cout<<' ';
    }
    cout<<endl;
  }
}
int main(){
  int n;
  cin>>n;
  input(n);
  mk_am(n);
  print(n);
  return 0;
}

C++: #include <iostream>
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;
        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;
    }
}