Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kombinatorika-parollar-soni

Number of passwords

Easy 1000 ms 128 MB 23%
Share

A password is exactly $n$ characters long. Each character is one of $k$ letters or one of $m$ digits (letters and digits are different characters). The password must contain at least one digit. How many different passwords can be made? Print the answer modulo $10^{9} + 7$.

Password cells: each cell holds a letter or a digit, at least one is a digit

Input

One line with three positive integers: $n$, $k$ and $m$.

Output

One integer — the number of passwords modulo $10^{9} + 7$.

Note

$1 \le n \le 10^{18}$
$1 \le k, m \le 10^{9}$

Examples

Input #1
2 3 2
Output #1
16
Input #2
1 5 1
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.