Under construction

Still being built. Things may change

Magic Show

Time limit1sMemory limit2048 MB

Summary
Alice must build a tree on n vertices so that Bob, given the tree after Catherine removes up to (n-2)/2 edges, can recover a number X up to 10^18.
Level

Hard8 of 10

Topics
Graph, Math, Implementation
Solved
No attempts yet

Problem

Alice and Bob are famous magicians. Catherine, a wealthy woman who was interested in their remarkable feats, declared that she would give them a huge fortune if they could perform the following magic trick. The trick goes as follows:

  • Step 1: Bob enters a room and is completely cut off from the outside. Bob can only communicate with Catherine. Then Alice tells Catherine a number nn between 2 and 5 0005\, 000.
  • Step 2: Catherine tells Alice a number XX between 1 and 101810^{18}.
  • Step 3: Alice builds a tree with exactly nn vertices and gives it to Catherine.
  • Step 4: Catherine deletes at most ⌊n−22⌋\left\lfloor \frac{n-2}{2} \right\rfloor edges from the tree and gives the remaining edges to Bob.
  • Step 5: Bob studies the graph carefully and says the number that Catherine told Alice.

However, Alice and Bob do not think they are clever enough to pull off this trick, so they ask for your help. Write a program that implements Alice's strategy and Bob's strategy.

Constraints

1≤X≤10181 ≤ X ≤ 10^{18}.

Examples1

  1. Example 1

    Input
    2
    1
    
    Expected output
    1 2