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<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string.h>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

int n;
int adj[105][105];

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  int n,p,q;
  cin>>n;
  int a[100][100]={};
  for (int i=0;i<n;i++){
    cin>>q>>p;
    if (p!=0){
      for (int j=0;j<p;j++){
	a[i][j]=1;
      }
    }
  }
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      cout<<a[i][j];
      if (j!=n-1)cout<<" "; 
    }
    cout<<endl;
  }
  return 0;
}

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 k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j];
            if(j != n-1)
            cout << " ";
        }
        cout << endl;
    }
}

C++: #include<stdio.h>
#define N 102

int main(){
  int a[N][N];
  int n,i,j,u,k,v;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      a[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1) printf(" ");
      printf("%d",a[i][j]);
    }
    printf("\n");
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int judge(int i,int n,int variable,vector< vector<int> > &v)
{
  for(int j=0;j<v[variable].size();++j){
    if(i==v[variable][j]){
      return 1;
      break;
    }
  }
  return 0;
}
int main()
{
  int n,u,k,vv;
  cin>>n;
  vector< vector<int> > v(n),a(n,vector<int>(n));
  for(int variable=0;variable<n;++variable){
    cin>>u>>k;
    for(int i=0;i<k;++i){
      cin>>vv;
      v[variable].push_back(vv);
    }
  }
  for(int variable=0;variable<n;++variable)
    for(int i=1;i<=n;++i)
      a[variable][i-1]=judge(i,n,variable,v);
  for(int variable=0;variable<n;++variable){
    for(int i=0;i<n;++i){
      cout<<a[variable][i]<<" "<<flush;
    }
    cout<<endl;
  }
}

C++: #include <cstdio>

int main(){
    int i, j, n, u, k, v;
    scanf("%d",&n);
    int A[n][n];
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            A[u-1][v-1] = 1;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            printf("%d",A[i][j]);
            if(j<n-1)printf(" ");
        }
        printf("\n");
    }
    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>
using namespace std;

int main(){
	int n,m,l,i,j,p;
	cin >> n;
	int f[101][101];
	for ( i = 0; i < n; i++){
		cin >> m;
		cin >> p;
		for ( j = 0; j < p; j++){
			cin >> l;
			f[m-1][l-1] = 1;
		}
	}
	for ( i = 0; i < n; i++){
		for ( j = 0; j < n-1; j++){
			cout << f[i][j] << " ";
		}
		cout << f[i][n-1] << endl;
	}
}

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

int main() {
    int M[N][N]; // adjecent matrix
    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 <vector>
using namespace std;

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

    int nb_nodes; cin >> nb_nodes;
    vector<vector<int>> graph( nb_nodes, vector<int>(nb_nodes, 0));
    
    int node;
    while (cin>>node){
        int nb_edges; cin >>nb_edges;
        int edge;
        for (int i=0; i<nb_edges; ++i){
            cin >> edge;    
            graph[node-1][edge-1] = 1;
        }
    }
    
    for(auto& a:graph){
        for(auto&& b:a) cout<<b<<(&b!=&a.back()? " ":"\n");
    }
}

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

int x[15000][15000],n,q,r,b;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> q >> r;
		for (int j = 0; j < r; j++) {
			cin >> b;
			x[i][b] = true;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) { cout << ' '; }
			cout << x[i][j+1];
		}
		cout << endl;
	}
	return 0;
}