ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1157. Young Tiler

Time limit: 1.0 second
Memory limit: 64 MB
One young boy had many-many identical square tiles. He loved putting all his tiles to form a rectangle more, than anything in the world — he has learned the number of all rectangles he can form using his tiles. On his birthday he was presented a number of new tiles. Naturally, he started forming rectangles from these tiles — the thing he loved most of all! Soon he has learned all rectangles he could form with a new number of tiles.
Here we should notice that boy can easily count the number of rectangles, but he has difficulty counting the number of tiles — there are too much of them for such a young boy. But it will not be difficult for you to determine how many tiles he has now, knowing how many rectangles he could form before, how many rectangles he can form now, and how many tiles he got as a birthday present.
You are given numbers M, N and K. You should find the smallest number L, such as you can form exactly N different rectangles using all L tiles, and form exactly M different rectangles using LK tiles.

Input

One line containing three integers: M, N, K (1 ≤ M, N ≤ 50; 1 ≤ K ≤ 9999).

Output

If L is less than or equal to 10000, then print that number (if there is a number of such L, you should print the smallest one). If there is no solution or smallest L is greater than 10000, print 0.

Sample

inputoutput
2 3 1
16
Problem Source: Ural Collegiate Programming Contest, April 2001, Perm, English Round