Problem:
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered.  This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source.  DFS timestamps each vertex as follows:    * $d[v]$ records when $v$ is first discovered.   * $f[v]$ records when the search finishes examining $v$’s adjacency list.  Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules:    * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively.   * IDs in the adjacency list are arranged in ascending order.   * The program should report the discover time and the finish time for each vertex.   * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID.   * The timestamp starts with 1.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-
N = int(input())
adj = [[0]*N for _ in range(N)]
searched = {n: 0 for n in range(N)}
edge = {}

def find_all(list_, x, j=-1):
    return [i for i, n in enumerate(list_) if n==1 and n != j]


for n in range(N):
    inp = list(map(int, input().split()))
    edge[n] = inp[1]
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = 1

time = 1
stack = []
unsearch = set(range(N))
uncomplete = set(range(N))
result = {n:{"found": 0, "finish": 0} for n in range(N)}

while len(unsearch) > 0 or len(stack) > 0:
    if len(stack) == 0:
        i = min(unsearch)
        result[i]["found"] = time
        unsearch.remove(i)
        time += 1

    
    while True:
        j = i
        for n in sorted(unsearch):
            if adj[i][n] == 1:
                j = n
                result[n]["found"] = time
                unsearch.remove(n)
                stack.append(i)
                time += 1
                break

        if i == j:
            result[i]["finish"] = time
    
            if len(stack) != 0:                
                i = stack.pop()
                time += 1
            else:
                break
        else:
            i = j
                
for n in range(N):
    print("{} {} {}".format(n, result[n]["found"], result[n]["finish"]))

Fixed, accepted submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(100000)
N = int(input())
adj = [[0]*N for _ in range(N)]
searched = {n: 0 for n in range(N)}
edge = {}

for n in range(N):
    inp = list(map(int, input().split()))
    edge[n] = inp[1]
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = 1

time = 1
stack = []
unsearch = set(range(N))
uncomplete = set(range(N))
result = {n:{"found": 0, "finish": 0} for n in range(N)}

def DFS(i):
    global time
    global unsearch
    
    itr = sorted(unsearch)
    
    for j in itr:
        if adj[i][j] == 1 and j in unsearch:
            result[j]["found"] = time
            time += 1
            unsearch.remove(j)
            DFS(j)
    result[i]["finish"] = time
    time += 1
    
while len(unsearch):
    i = min(unsearch)
    unsearch.remove(i)
    result[i]["found"] = time
    time += 1
    DFS(i)

for n in range(N):
    print("{} {} {}".format(n+1, result[n]["found"], result[n]["finish"]))