from sys import stdin
from random import randint
class Vertex():
    def __init__(self):
        self.detective = False
        self.near_bank = []


def read_data():
    a = list(map(int, input().split()))
    detectives = a[1]
    banks = a[0]
    connections = []
    for _ in range(banks-1):
        connections.append(list(map(int, input().split())))

    return connections, banks, detectives

def initialize():
    '''
    Defend = True
    Attack = False
    '''
    role = input()
    if role == 'DEFEND':
        role = True
    else:
        return False, []
    if role:
        start_detective_positions = list(map(int, input().split()))
        return role, start_detective_positions

def create_graph(banks, positions, connections):
    Graph = []
    for _ in range(banks):
        Graph.append(Vertex())
    for a in connections:
        Graph[a[0]].near_bank.append(a[1])
        Graph[a[1]].near_bank.append(a[0])
    for b in positions:
        Graph[b].detective = True
    return Graph

def simulate_attack(graph):
    attack = randint(0, len(graph)-1)
    while graph[attack].detective:
        attack = randint(0, len(graph) - 1)
    return attack

def defence(graph):
    moves = list(map(int, input().split()))
    if len(moves) == 1:
        return graph
    else:
        for a in range(1,moves[0]*2, 2):
            graph[moves[a]].detective = False
            graph[moves[a+1]].detective = True
        return graph

def check_rules(attack, graph):
    if graph[attack].detective:
        return True
    else:
        return False

def start_pos(det):
    pos = []
    while len(pos)!= det:
        a = randint(0, det)
        if a not in pos:
            pos.append(a)
    return pos

def simulate_defence(graph, attacked_bank):
    moves = 0
    move = []
    to_check = graph[attacked_bank].near_bank
    for a in to_check:
        if graph[a].detective:
            moves+=1
            move.append(a)
            move.append(attacked_bank)
            break
    move.insert(0, moves)

    if moves == 0:
        return graph, [0]
    else:
        for a in range(1,move[0]*2, 2):
            graph[move[a]].detective = False
            graph[move[a+1]].detective = True

    return  graph, move

def find_positions(graph):
    positions = []
    for a in range(len(graph)):
        if graph[a].detective:
            positions.append(a)
    return positions


connections, banks, detectives = read_data()
role, detectives_positions = initialize()

if role:
    graph = create_graph(banks, detectives_positions, connections)
    for _ in range(365):
        '''Gra dla obroÅcy'''
        attacked_bank = simulate_attack(graph)
        if(attacked_bank == -1):
            break
        print(attacked_bank)
        stdin.flush()
        graph = defence(graph)
        if check_rules(attacked_bank, graph):
            continue
        else:
            break


else:
    '''Gra dla atakujÄcego'''
    detectives_positions = start_pos(detectives)
    graph = create_graph(banks, detectives_positions, connections)
    print(' '.join(map(str, detectives_positions)))
    for _ in range(365):
        attacked_bank = int(input())
        if (attacked_bank == -1):
            break
        stdin.flush()
        graph, moves = simulate_defence(graph, attacked_bank)

        if check_rules(attacked_bank, graph):
            print(' '.join(map(str, moves)))
            continue
        else:
            break





