Under construction

Still being built. Things may change

Hair War

Time limit1sMemory limit1024 MB

Summary
Given a complete binary tree with N broken edges, compare a fork-splitting search against a left-first DFS with return costs, and report which finishes faster.
Level

Medium5 of 10

Topics
Tree, DFS, Simulation
Solved
No attempts yet

Problem

Blobs have always sought novelty. This time, the blobs wanted a new feel, so they prayed to the sky every day.

Tokka heard the prayers and gave the blobs twin-tail hair, and the blobs entered the Great Twin-Tail Era.

Twin-tail blob

Some blobs wanted an even newer hairstyle, so they tied their hair up and became ponytail blobs.

Twin-tail blobs grieving the arrival of ponytail blobs

At first, ponytail blobs were brushed off as strange blobs. But their number grew one by one until it was close to the number of twin-tail blobs.

The twin-tail blobs and ponytail blobs came to hate each other more and more, and the Hair War broke out!

The blobs love peace, so instead of a bloody war, they agreed to a contest of skill. Tokka chose the Twin-Tail Cave as the venue. The cave was once the main mining site of the blobs. When mining was active, it was a complete binary tree from the entrance down to depth DD, with 2D−12^D-1 rooms in total. A passage connected room ii and room ⌊i2⌋\left \lfloor \frac{i}{2} \right \rfloor for 2≤i≤2D−12 \le i \le 2^D-1.

However, mining declined and the cave has been unused for a long time. NN passages are broken, and they cannot be traveled for the search.

Still, the war had to be fought. They decided that the faction that searches all rooms except the unreachable ones fastest wins.

By default, moving from one room to an adjacent room takes UU for a blob. The twin-tail and ponytail blobs chose different search methods.

Whenever twin-tail blobs reach a fork, they split their force in half and search. A force can be split at any time, since there are always enough blobs to split. But each split increases the time to move between adjacent rooms by TT for the split group.

The twin-tail blobs search simultaneously, so their search time is the total time of the team that took the longest.

Ponytail blobs search together in one direction. At a fork, they go left first. When there are no more rooms to search, they go back up. Note that this also costs UU of search time.

Each blob's clock advances only by the search time of each passage it traverses, and other time is ignored. The search ends as soon as all rooms are searched.

The figure below shows the twin-tail blobs' method on the left and the ponytail blobs' method on the right.

The war is declared and the search begins! Find which faction wins this war.

Input

The first line contains four integers D(1≤D≤12)D(1 \le D \le 12), N(0≤N≤2D−2)N(0 \le N \le 2^D-2), U(1≤U≤100)U(1 \le U \le 100), and T(U<T≤150)T(U < T \le 150), separated by spaces. They are the depth of the deepest room of the cave, the number of broken passages, the default search time of each blob faction, and the extra time added to a twin-tail group each time it splits.

All of DD, NN, UU, and TT are integers.

From the second line, the next NN lines each contain s,e(1≤s<e≤2D−1)s, e(1 \le s < e \le 2^D-1), the endpoints of a broken passage, separated by a space. No passage appears more than once.

Output

If the twin-tail blobs finish the search faster, print :blob_twintail_aww:. If the ponytail blobs finish faster, print :blob_twintail_sad:.

If both blobs finish the search at the same time, print :blob_twintail_thinking:.

Examples3

  1. Example 1

    Input
    3 1 2 3
    1 2
    
    Expected output
    :blob_twintail_aww:
    
  2. Example 2

    Input
    4 3 1 4
    2 5
    3 7
    6 12
    
    Expected output
    :blob_twintail_sad:
    
  3. Example 3

    Input
    1 0 1 2
    
    Expected output
    :blob_twintail_thinking: