Go: package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve(parseProblem())
}

type graph struct {
	size  int
	edges [][]int
}

func parseProblem() *graph {
	n := scanInt(sc)
	g := &graph{
		size:  n,
		edges: make([][]int, n),
	}
	for i := 0; i < g.size; i++ {
		_ = scanInt(sc)
		k := scanInt(sc)
		g.edges[i] = make([]int, k)
		for j := 0; j < k; j++ {
			g.edges[i][j] = scanInt(sc) - 1
		}
	}
	return g
}

func resolve(g *graph) {
	ds := make([]int, g.size)
	fs := make([]int, g.size)
	time := 0
	for i := 0; i < len(ds); i++ {
		if ds[i] == 0 {
			time++
			time = _dfs(ds, fs, time, g, i)
		}
	}
	for i := 0; i < len(ds); i++ {
		fmt.Println(i+1, ds[i], fs[i])
	}
	return
}

func _dfs(ds, fs []int, time int, g *graph, idx int) int {
	ds[idx] = time
	for _, next := range g.edges[idx] {
		if ds[next] > 0 {
			continue
		}
		time++
		time = _dfs(ds, fs, time, g, next)
	}
	time++
	fs[idx] = time
	return time
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

C++: #include <iostream>
using namespace std;
int g[101][102],ch[101][2]={0},kh;

int dfs(int k,int n){
  ch[n][0]=k;
  //cout<<k<<n<<"<--"<<endl;/////////
  for(int i=1;i<=g[n][0];i++){
    if(ch[g[n][i]][0]==0){
      k=dfs(k+1,g[n][i]);
    }
  }
  ch[n][1]=k+1;
  kh=k+1;
  return k+1;
}

int main(){
  int a,b,c,d;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b>>c;
    g[b][0]=c;
    for(int j=1;j<=c;j++){
      cin>>d;
      g[b][j]=d;
    }
  }
  kh=0;
  for(int i=1;i<=a;i++){
    if(ch[i][0]==0){
      //cout<<i<<"<--"<<endl;////////
      dfs(kh+1,i);
    }
  }
  
  for(int i=1;i<=a;i++){
    cout<<i<<" "<<ch[i][0]<<" "<<ch[i][1]<<endl;
    
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
struct Node{
  int u;
  int k;
  int v[99];

  int start;
  int finish;
};

int deep(Node nod[],int x,int count){
  if(nod[x].start)
    return count;

  nod[x].start=(++count);
  cout << nod[x].u << " " << count << endl;
  for(int i=0; i<nod[x].k; i++)
    count = deep(nod,nod[x].v[i]-1,count);

  nod[x].finish= (++count);
  return count;
}

int main(){
  int n,count=0;
  Node nod[100];

  cin >> n;
  for(int i=0; i<n; i++){
    cin >> nod[i].u >> nod[i].k;
    
    for(int j=0; j<nod[i].k; j++)
      cin >> nod[i].v[j];
    
    nod[i].start=0;
    nod[i].finish=0;
  }

  for(int i=0; i<n; i++)
    count = deep(nod,i,count);
  
  for(int i=0; i<n; i++){
    cout << nod[i].u << " " << nod[i].start << " " << nod[i].finish << endl;
  }
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
int counter=0;

int addedge(vvi &graph, int y, int x, int val=1){
	graph[y][x] = val;
	return val;
}

int make_graph(vvi &graph, vvi &stamp){
	int n1=graph.size(), n2, row, col;

	for (int j=0; j<n1; j++){
		cin>>row;
		cin>>n2;
		for (int i=0; i<n2; i++){
			cin>>col;
			addedge(graph, row-1, col-1);
		}
		stamp[j][0] = -1;
	}
	return 0;
}

int Depth_First_Search(vvi &graph, vvi &stamp, int key=0){
	if (stamp[key][0] != -1) return 0;
	stamp[key][0] = ++counter;
	for (int i=0; i<int(graph[0].size()); i++){
		if (graph[key][i]==1 && stamp[i][0]==-1){
			Depth_First_Search(graph, stamp, i);
		}
	}
	stamp[key][1] = ++counter;
	return 0;
}

int resultout(vvi &stamp){
	for (int i=0; i<int(stamp.size()); i++){
		cout<<i+1<<" "<<stamp[i][0]<<" "<<stamp[i][1]<<endl;
	}
	return 0;
}

int main(void){

	int n, row;
	cin>>n;
	vvi G(n, vi(n)), stamp(n, vi(2));

	make_graph(G, stamp);

	Depth_First_Search(G, stamp);

	resultout(stamp);

	return 0;
}

C++: #include <iostream>

using namespace std;

const int N = 100;
int A[N][N] = {{0}};
int n;
int t = 0;
int d[N] = {0};
int f[N] = {0};

void dfs(int id) {
    if (d[id] != 0) {
        return;
    }
    ++t;
    d[id] = t;

    for (int i = 0; i < n; ++i) {
        if (A[id][i] != 0) {
            dfs(i);
        }
    }

    ++t;
    f[id] = t;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u;
        cin >> u;

        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            A[u-1][x-1] = 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (d[i] == 0)
            dfs(i);
    }

    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " ";
        cout << d[i] << " " << f[i];
        cout << endl;
    }

    return 0;
}