Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Classmates
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 138Accepted: 54

Description

Mike graduated from high school several years ago. One day a question suddenly comes to his mind: how many classmates did he have in his high school? He doesn’t remember, and it's obviously too hard for him to recall everyone. But he does remember something - a game played on a New Year's Day. Because all his classmates had joined that game, Mike thinks he can figure out the number of his classmates by some clues.

The game went like this: At first, all classmates stood one by one in a circle, labeled clockwisely from No.1 to No. n. Of course n is the total number of all classmates. Then, starting from the No. 2 guy, they kicked out every 2nd guy. After each guy was kicked out, counting and kicking continued around the circle that remained, until there was only one guy left. That luck guy would get a gift. As shown in the picture below, if there were 6 classmates in the game, the people been kicked out would be in the order of No.2, No.4, No.6, No.3 and No.1, and in the end the No. 5 guy would win the gift.



Mike can only remember what number he was labeled, and how many classmates still remained in the circle when he was going to be kicked out. You should help him calculate the minimum possible total number of his classmates.

Input

The input consists of several cases. Every case is one line with two positive integer m and k(1<=m<=100,000,000, 1<=k<=100,000,000). m is Mike's number in the game, and k is the total number of people remained in the circle when Mike was going to be kicked out. (Mike was among those k people)

The input ends with a line containing two zero.

Output

For each test case, you should print the minimum possible total number of Mike’s classmates. If it’s impossible to find that number according to the input, please print "Impossible".
You may assume that the answer fits in a signed 64-bit integer.

Sample Input

1 1
3 3
53 9
100 2
999999999 999999999
0 0

Sample Output

1
6
60
Impossible
2499999996

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator