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>
using namespace std;

int main(){
  int n,u,k,v;
  int G[100][100]={};

  cin >> n;
  for (int i=0;i<n;i++){
    cin >>u>>k;
    for (int j=0;j<k;j++){
      cin >> v;
      G[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for (int j=0;j<n-1;j++){
      cout << G[i][j]<<" ";
    }
    cout << G[i][n-1]<<endl;
  }
  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 <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];
      if(j!=n-1)cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

C++: # include <iostream>
# include <cstring>
# include <cstdio>
using namespace std;
int main(void)
{
	int a[105][105];
    int n,cnt,u,k;
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    for(int w = 0;w < n;w++)
    {
    	scanf("%d %d",&u,&cnt);
    	for(int i = 0;i < cnt;i++)
    	{
    		scanf("%d",&k);
    		a[u][k] = 1;
		}
	}
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++) cout<<a[i][j]<<(j == n?"\n":" ");
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n, vector<int>(n, 0));

    for (int y = 0; y < n; y++) {
        int num, k;
        cin >> num >> k;
        for (int i = 0; i < k; i++) {
            int x;
            cin >> x;
            x--;
            G[x][y] = 1;
        }
    }

    for (int y = 0; y < n; y++) {
        cout << G[0][y];
        for (int x = 1; x < n; x++) {
            cout << " " << G[x][y];
        }
        cout << endl;
    }

    return 0;
}

C++: /* ALDS1_11_A: Graph */

#include <iostream>

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    std::cin >> n;

    int adjm[n + 1][n + 1];
    for (int row = 1; row <= n; row++)
        std::fill_n(adjm[row], n + 1, 0);

    int u, v, n_degrees;
    for (int i = 0; i < n; i++) {
        std::cin >> u >> n_degrees;
        for (int j = 0; j < n_degrees; j++) {
            std::cin >> v;
            adjm[u][v] = 1;
        }
    }

    for (int row = 1; row <= n; row++) {
        std::cout << adjm[row][1];
        for (int col = 2; col <= n; col++) {
            std::cout << " " << adjm[row][col];
        }
        std::cout << "\n";
    }


    return 0;
}

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

using namespace std;

bool mat[105][105];
int n;
void print(bool x){
    if(x) cout<<"1 ";
    else cout<<"0 ";
}
int main(){
    cin>>n;
    int t=n;
    memset(mat,false,sizeof(mat));
    while(t--){
        int id,k;
        cin>>id>>k;
        while(k--){
            int out;
            cin>>out;
            mat[id][out]=true;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            print(mat[i][j]);
        }
        cout<<endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int Adj[n][n];
    int A[n][n];
    int g1, g2;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j] = 0;
            A[i][j] = 0;
        }
    }

    for(int i=0;i<n;i++){
        cin >> g1 >> g2;
        for(int j=0;j<g2;j++){
            cin >> Adj[i][j];
            A[i][Adj[i][j]-1] = 1;
        }
    }

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

C++: /*
** 邻接表和邻接矩阵来保存图
*/

# include <cstdio>
# include <cstring>

const int MAX = 100 + 2;

int m[MAX][MAX];

int n;

void solve() {
    scanf("%d", &n);
    memset(m, 0, sizeof(m));
    int u, k, v;
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &u, &k);
        while (k-- > 0) {
            scanf("%d", &v);
            m[u-1][v-1] = 1;
        }
    }
        

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) {
                printf(" ");
            }
            printf("%d", m[i][j]);
        }
        printf("\n");
    }
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}

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

int main() {
	int n, u, v, l;
	cin >> n;
	int A[n + 1][n + 1];
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			A[i][j] = 0;
		}
	}

	for (int i = 1; i <= n; i++) {
		cin >> u >> l;
		for (int j = 0; j < l; j++) {
			cin >> v;
			A[u][v] = 1;
		}
	}

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

	return 0;
}