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;

struct Vertex
{
    int id, k, *adjcent, start, end;
    bool passed = false;
};

Vertex *vertexs;
int time_ = 0;

void DFS(int now)
{
    vertexs[now].passed = true;
    time_++;
    vertexs[now].start = time_;
    for(int i=0; i<vertexs[now].k; i++)
    {
        if(!vertexs[vertexs[now].adjcent[i]].passed) DFS(vertexs[now].adjcent[i]);
    }
    time_++;
    vertexs[now].end = time_;
}

int main()
{
    int n;
    scanf("%d", &n);
    vertexs = new Vertex[n+1];
    for(int i=1; i<=n; i++)
    {
        scanf("%d%d", &vertexs[i].id, &vertexs[i].k);
        vertexs[i].adjcent = new int[vertexs[i].k];
        for(int j=0; j<vertexs[i].k; j++)
        {
            scanf("%d", &vertexs[i].adjcent[j]);
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(!vertexs[i].passed) DFS(vertexs[i].id);
    }
    for(int i=1; i<=n; i++) printf("%d %d %d\n", vertexs[i].id, vertexs[i].start, vertexs[i].end);

    return 0;
}

C++: #include <iostream>
#define N 110

int t = 1;

int d[N], f[N];
int A[N][N];

void Depth(int id, int n){
  d[id] = t;
  t++;
  for(int i=1; i<=n; i++){
    if(A[id][i] == 1 && d[i] == 0){
      Depth(i, n);
    }
  }
  f[id] = t;
  t++;
}



int main(){
  for(int i=0; i<N; i++){
    d[i]=f[i]=0;
    for(int j=0; j<N; j++){
      A[i][j]=0;
    }
  }
  int n;
  std::cin >> n;
  for(int i=0; i<n; i++){
    int u, k, v;
    std::cin >> u >> k;
    for(int i=0; i<k; i++){
      std::cin >> v;
      A[u][v]=1;
    }
  }
  for(int i=1; i<=n; i++){
    if(d[i] == 0 && f[i] == 0){ Depth(i, n); }
  }
  for(int i=1; i<=n; i++){
    std::cout << i << " " << d[i] << " " << f[i] << std::endl;
  }

  return 0;
}

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

using namespace std;

vector<int> G[110];

int timer;
int d[110],f[110];

bool used[110];

void dfs(int x)
{
    used[x]=true;
    d[x]=++timer;

    for(int i=0;i<G[x].size();i++)
    {
        if(!used[G[x][i]])
        {
            dfs(G[x][i]);
        }
    }

    f[x]=++timer;
}


int main()
{

    int n;

    cin>>n;

    for(int i=0;i<n;i++)
    {
        int a,b,c;

        cin>>a>>b;

        for(int i=0;i<b;i++)
        {
            cin>>c;

            G[a].push_back(c);
        }
    }

    timer=0;
    memset(used,0,sizeof(used));

    for(int i=1;i<=n;i++)
    {
        if(!used[i])
        {
            dfs(i);
        }
    }

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

    return 0;
}

C++: #include <iostream>
#include <stack>
#define MAX 101
#define NIL -1

using namespace std;


int matrix[MAX][MAX] = {0};
int d[MAX], f[MAX];
int n, t;

void dfs();
void dfs_visit(int u);
int next(int u);

int main()
{
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		int u, k, v;
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> v;
			matrix[u][v] = 1;			
		}
	}
	
//显示邻接矩阵 
//	for (int i = 0; i < n; i++)
//	{
//		for (int j = 0; j < n; j++)
//		{
//			if(j) cout << ' ';
//			cout << matrix[i+1][j+1];		
//		}
//		cout << endl;
//	}
	
	
	dfs();
	
	
	for (int i = 1; i <= n; i++)
	{
		cout << i << ' ';
		cout << d[i] << ' ';	
		cout << f[i] << endl;
	}
} 



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



void dfs_visit(int u)
{

	stack<int> S;
	S.push(u);
	d[u] = ++t;
	
	while (!S.empty())
	{
		u = next(S.top());
		if (u)
		{
//			if (d[u] == 0)
			{
			d[u] = ++t;
			S.push(u); 				
			}
		}
		else
		{
			f[S.top()] = ++t;
			S.pop();
		}
		
	}
	
}


int next(int u)
{
	for (int i = 1; i <= n; i++)
	{
		if (matrix[u][i] != 0 && d[i] == 0)
			return i;
	}
	return 0;
}

C++: #include <iostream>
#include <list>
#include <vector>

struct TNode
{
	int Index;
	bool Visited;
	std::list<TNode*> Target;
	
	int ClockStart;
	int ClockEnd;
	
	TNode(int AIndex)
	: Index(AIndex), Visited(false), ClockStart(0), ClockEnd(0)
	{
	}
	
	void Visit(int& Clock)
	{
		if(Visited) return;
		Visited = true;
		ClockStart = Clock;
		++Clock;
		for(std::list<TNode*>::iterator It = Target.begin(); It != Target.end(); ++It){
			(*It)->Visit(Clock);
		}
		ClockEnd = Clock;
		++Clock;
	}
};

class TGraph
{
	std::vector<TNode*> FNodes;
public:
	TGraph(int Count)
	: FNodes(Count)
	{
		for(int i = 0; i < Count; ++i){
			FNodes[i] = new TNode(i + 1);
		}
	}
	
	~TGraph()
	{
		for(unsigned int i = 0; i < FNodes.size(); ++i){
			delete FNodes[i];
		}
	}
	
	void InputNode(int Index, int BranchCount)
	{
		for(int i = 0; i < BranchCount; ++i){
			int Target;
			std::cin >> Target;
			FNodes[Index - 1]->Target.push_back(FNodes[Target - 1]);
		}
	}
	
	void DepthFirstSearch()
	{
		int Clock = 1;
		for(unsigned int i = 0; i < FNodes.size(); ++i){
			FNodes[i]->Visit(Clock);
		}
	}
	
	void OutputClocks()const
	{
		for(unsigned int i = 0; i < FNodes.size(); ++i){
			std::cout << FNodes[i]->Index      << " "
			          << FNodes[i]->ClockStart << " "
			          << FNodes[i]->ClockEnd   << std::endl;
		}
	}
};

int main()
{
	int Count;
	std::cin >> Count;
	TGraph Graph(Count);
	for(int i = 0; i < Count; ++i){
		int Index;
		std::cin >> Index;
		int BranchCount;
		std::cin >> BranchCount;
		Graph.InputNode(Index, BranchCount);
	}
	Graph.DepthFirstSearch();
	Graph.OutputClocks();
	return 0;
}