Under construction

Still being built. Things may change

Lazy Student

Time limit1sMemory limit256 MB

Summary
Given k exam days, find the minimum expected fraction of topics Raccoon must learn, where each attempt passes with probability equal to the fraction learned, modulo 1000000007.
Level

Hard8 of 10

Topics
Probability, Math, Dynamic programming
Solved
No attempts yet

Problem

The Algorithms course exam is coming soon, and there are kk days when you can attempt it. You can come on any subset of the days until you finally pass. Raccoon, a young lazy student, definitely wants to pass, but he also wants to learn as few topics as possible. If only one exam day is left, he has to learn all the topics. If there are 10 attempts, he may hope that learning a third of the topics is enough.

Here is the process in detail. All topics form the segment [0,1][0,1]. Raccoon learns the first xx topics, where xx is a real number from 00 to 11. When he comes to an exam day, he passes with probability xx. He may learn more topics before the exams or between attempts, and he never forgets what he has learned. For example, he may learn 13\frac{1}{3} before the first exam day and then 16\frac{1}{6} after a failure, reaching a total of 12\frac{1}{2}. If he fails on every day before the last one, he learns all the topics before the last attempt, because he definitely wants to pass.

Raccoon does not want to learn much. He chooses the strategy that gives the smallest expected amount of topics he has to learn. What is this expected amount?

Input

A single integer kk is given: the number of attempts to pass the exam (1≤k≤10181 \le k \le 10^{18}).

Output

The answer can be written as an irreducible fraction PQ\frac{P}{Q}. Print P mod MP \bmod M and Q mod MQ \bmod M separated by a space, where M=1 000 000 007M = 1\,000\,000\,007.

Hint

For the first input (when there are just 22 exam days), Raccoon may learn 12\frac{1}{2} of all topics before the first attempt, and another 12\frac{1}{2} if he fails on the first day. The expected amount of topics to be learned is therefore 12⋅12+12⋅1=34\frac{1}{2} \cdot \frac{1}{2} + \frac{1}{2} \cdot 1 = \frac{3}{4}.

Examples2

  1. Example 1

    Input
    2
    
    Expected output
    3 4
    
  2. Example 2

    Input
    3
    
    Expected output
    39 64