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>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <functional>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
using vb = vector<bool>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(int i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) { ll prime; double sqrtmax = sqrt(max); vector<ll> primeVec, searchVec; FOR(i, 2, max + 1) searchVec.push_back(i); do { prime = searchVec[0]; primeVec.push_back(prime); auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; }); searchVec.erase(itr, searchVec.end()); } while (prime < sqrtmax); primeVec.reserve(primeVec.size() + searchVec.size()); primeVec.insert(primeVec.end(), beginend(searchVec)); return primeVec; }
bool isPrime(ll x) { if (x == 2) return true; if (x < 2 || x % 2 == 0) return false; ll i = 3; while (i <= sqrt(x)) { if (x%i == 0) return false; i += 2; }return true; }
vi seq(int max, int start = 0) {vi rt(max - start+1);FOR(i, start, max+1) rt[i] = i;return rt;}
template<typename T> size_t find_first_of(vector<T> v, T val) { auto itrfind = find(beginend(v), val); size_t dis = distance(v.begin(), itrfind); if (dis == v.size()) { return -1; }return dis; }
template<class T> struct Identity {typedef T type;};
template<typename T> vector<T> select(const vector<T> &v, typename Identity<function<T(const T &)>>::type ft) {vector<T> rt; for (T item : v) { rt.push_back(ft(item)); }return rt;}
template<typename T> string join(const vector<T> &v, typename Identity<function<string(const T &)>>::type ft) {string rt = "";Foreach(x, v) {rt += ft(x);}return rt;}



int d[105]{ 0 }, f[105]{ 0 };
int _time = 1;
int N;
void dfs(vvi & box,int v) {
	if (d[v] != 0) return;
	d[v] = _time++;
	for (int i = 0; i < N; i++) if (box[v][i] != 0) {
		dfs(box,i);
	}
	f[v] = _time++;
	return;
}

int main(){
	cin >> N;
	vvi box(N, vector<int>(N, 0));
	REP(i, N) {
		int v, k, u;
		cin >> v >> k;
		REP(n, k) {
			cin >> u;
			box[i][u-1] = 1;
		}
	}
	dfs(box, 0);

	REP(i, N) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int a[120][120],b[120][2],u,k,v,n,cou=1;
void dfs(int i){
  b[i][0]=cou;
  cou++;
  for(int j=1;j<=n;j++){
    if(a[i][j]==1&&b[j][0]==0)dfs(j);
  }
  b[i][1]=cou;
  cou++;
}

int main(){
  cin>>n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      a[i][j]=0;
      b[i][0]=0;
      b[i][1]=0;
    }
  }
  for(int i=1;i<=n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      a[u][v]=1;
    }
  }
  dfs(1);
  for(int i=1;i<=n;i++){
    cout<<i<<" "<<b[i][0]<<" "<<b[i][1]<<endl;;
  }
  return 0;
}

C++: #include<stdio.h>
#define N 100
#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 =0;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=0;u<n;u++)color[u]=WHITE;
  tt = 0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

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

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

int n,u,k,v;
int g[102][102];
int d[102],f[102];
int sn[102];
int cnt=1;

void dfs(int x);

int main(){
  memset(d,0,sizeof(d));
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>u>>k;
    sn[i]=0;
    for(int j=1;j<=k;j++){
      cin>>v;
      g[u][v]=1;
    }
  }
  
  for(int i=1;i<=n;i++){
    if(sn[i]==0){
      dfs(i);
    }
  }


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

  return(0);
}

void dfs(int x){
  
  sn[x]=1;
  d[x]=cnt;
  cnt++;
  
  for(int i=1;i<=n;i++){
    if(g[x][i]==1 && sn[i]==0){
      dfs(i);
    }
  }

  f[x]=cnt;
  cnt++;

}