Go: package main

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

// repr state of visited node
// WHITE yet visit
// GEAY  visiting
// BLACK visited
const (
	WHITE int = iota
	GRAY
	BLACK
)

type dfsGraph struct {
	g      [][]int
	colors []int
	stime  []int // Start time of visiting node
	ftime  []int // Finish time of visiting node
}

var time int

func makeAdjList() [][]int {
	var n int
	fmt.Scanf("%d", &n)

	adj := make([][]int, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]int, n)
	}

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		sc.Scan()
		nodeInfo := strings.Split(sc.Text(), " ")
		outDegree, _ := strconv.Atoi(nodeInfo[1])

		if outDegree > 0 {
			for k := 0; k < outDegree; k++ {
				j, _ := strconv.Atoi(nodeInfo[k+2])
				j-- // convert 1 based to 0 based
				adj[i][j] = 1
			}
		}
	}

	return adj
}

func (dg dfsGraph) dfsVisit(u int) {
	// 頂点uを訪問中に設定
	dg.colors[u] = GRAY
	time++
	dg.stime[u] = time

	// uの隣接nodeを訪問
	for v := 0; v < len(dg.g); v++ {
		if dg.g[u][v] == 0 {
			continue // 辺がなければスキップ
		}

		// vが未訪問なら訪問
		if dg.colors[v] == WHITE {
			dg.dfsVisit(v)
		}
	}

	// 頂点uを訪問済みに設定
	dg.colors[u] = BLACK
	time++
	dg.ftime[u] = time
}

func (dg dfsGraph) dfs() {
	for i := 0; i < len(dg.g); i++ {
		if dg.colors[i] == WHITE {
			dg.dfsVisit(i)
		}
	}
}

func (dg dfsGraph) printDfsTime() {
	for i := 0; i < len(dg.g); i++ {
		fmt.Printf("%d %d %d\n", i+1, dg.stime[i], dg.ftime[i])
	}
}

func main() {
	adj := makeAdjList()
	colors := make([]int, len(adj))
	stime := make([]int, len(adj))
	ftime := make([]int, len(adj))
	graph := dfsGraph{adj, colors, stime, ftime}
	graph.dfs()
	graph.printDfsTime()
}

C++: #include<stdio.h>
#define N 105
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[N][N];
int color[N],d[N],f[N],tt;
void dfs_visit(int u){
     int v;
     color[u]=GRAY;
     d[u]=++tt;
     for(v=1;v<=n;v++)
     {
         if(M[u][v]==0)continue;
         if(color[v]==WHITE){
            dfs_visit(v);
         }
     }
     color[u]=BLACK;
         f[u]=++tt;
}
void dfs(){
     int u;
     for(u=1;u<=n;u++)color[u]=WHITE;
     tt=0;
     for(u=1;u<=n;u++)
     {
         if(color[u]==WHITE)dfs_visit(u);
     }
     for(u=1;u<=n;u++){
        printf("%d %d %d\n",u,d[u],f[u]);
     }
}
int main()
{
    int u,v,k,i,j;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)M[i][j]=0;
    }
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&u,&k);
        //u--;
        for(j=1;j<=k;j++)
        {
            scanf("%d",&v);
        //v--;
            M[u][v]=1;
        }
    }
    dfs();
    return 0;
}

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

int N, T = 0; 
vector<vector<int>> G(110);

vector<int> d(110, -1), f(110, -1);

void dfs(int v){
  T++; d[v] = T;
  for(int i=0; i<G[v].size(); i++){
    int u = G[v][i];

    if(d[u] == -1){
      //cout << v << " " << u << " " << T << endl;
      dfs(G[v][i]);
    }
  }
  T++;
  f[v] = T;
}

int main(){ 
  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-1].push_back(v-1);
    }
  }

  for(int i=0; i<N; i++){
    if(d[i] == -1) dfs(i);
  }
  
  for(int id=0; id<N; id++){
    cout << id+1 << " "<< d[id] << " " << f[id] << endl; 
  }
}

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

void dfs(int n, int &t, vector<vector<int>>& g, vector<int>& d, vector<int>& f, vector<bool>& seen)
{
    t++;
    if (d[n] == 0) d[n] = t;
    seen[n] = true;
    for (int i = 0; i < g[n].size(); i++)
    {
        if (seen[g[n][i]]) continue;
        dfs(g[n][i], t, g, d, f, seen);
    }
    t++;
    f[n] = t;
}

int main()
{
    int n; cin >> n;
    vector<vector<int>> g(n, vector<int>());
    for (int i = 0; i < n; i++)
    {
        int u, k; cin >> u >> k; u--;
        for (int j = 0; j < k; j++)
        {
            int v; cin >> v; v--;
            g[u].push_back(v);
        }
    } 
    vector<int> d(n, 0);
    vector<int> f(n, 0);
    vector<bool> seen(n, false);
    int t = 0;
    for (int i = 0; i < n; i++)
        if (seen[i] == false)
            dfs(i, t, g, d, f, seen);
    for (int i = 0; i < n; i++)
    {
        cout << i + 1 << " " <<  d[i] << " " << f[i] << endl;
    }
}

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

int n;
int t; //mytime?????????????????§???????´?
int mytime1[110],mytime2[110]; //?????§??????
int G[110][110];
int c[110];

void dfs(int cur){
	t+=1;
	mytime1[cur]=t;
	c[cur]=1;
	for(int dst=0; dst<n; ++dst){
		if(G[dst][cur]==1&&c[dst]==0){
			dfs(dst);
			t += 1;
		}
	} 
	mytime2[cur]=t;
}


int main()
{
	vector<int> v[110];
	cin>>n;
	for(int i=0;i<n;i++){
		int u,k;
		cin>>u>>k;
		for(int j=0;j<k;j++){
			int tmp;
			cin>>tmp;
			v[u].push_back(tmp);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			G[i][j]=0;
		}
	}
	for(int i=1;i<n+1;i++){
		for(int j=0;j<v[i].size();j++){
			G[i-1][v[i][j]-1]=1; //
		}
	}
	dfs(0);
	for(int i=0;i<n;i++){
		cout<<(i+1)<<' '<<mytime1[i]<<" "<<mytime2[i] <<endl;
	}
}