# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""




import queue
def dfs(g,s): # depth first search 
    explore = {}
    result = []
    for e in list(g):
        explore[e] = -1
    explore[s] = 1
    q = queue.LifoQueue()
    q.put(s)
    while not q.empty():
        u = q.get()
        result.append(u)
        for e in g[u]:
            if explore[e] == -1:
                explore[e] = 1
                q.put(e)
    return result

    



ef0d951fae528d37846ce7cae0b54700e545b74a
<mask token>

<mask token>


def dfs(g, s):
    explore = {}
    result = []
    for e in list(g):
        explore[e] = -1
    explore[s] = 1
    q = queue.LifoQueue()
    q.put(s)
    while not q.empty():
        u = q.get()
        result.append(u)
        for e in g[u]:
            if explore[e] == -1:
                explore[e] = 1
                q.put(e)
    return result

<mask token>
import queue


def dfs(g, s):
    explore = {}
    result = []
    for e in list(g):
        explore[e] = -1
    explore[s] = 1
    q = queue.LifoQueue()
    q.put(s)
    while not q.empty():
        u = q.get()
        result.append(u)
        for e in g[u]:
            if explore[e] == -1:
                explore[e] = 1
                q.put(e)
    return result

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""




import queue
def dfs(g,s): # depth first search 
    explore = {}
    result = []
    for e in list(g):
        explore[e] = -1
    explore[s] = 1
    q = queue.LifoQueue()
    q.put(s)
    while not q.empty():
        u = q.get()
        result.append(u)
        for e in g[u]:
            if explore[e] == -1:
                explore[e] = 1
                q.put(e)
    return result

    


