2000 LSU Computer Science High School Programming Contest
Veteran Problem 1: Eeny Meeny

MAIN
  Home
  Schedule
  Rules
  Compile

RESULTS
  Results

PROBLEMS
  Novice
  Veteran
  All

  

In darkest <name of continent/island deleted to prevent offense> lived a tribe called the ``Eeny Meenys''. They got this name from their way of choosing a chief for a year. It appears that a newspaper reporter visited the tribe and managed to get across a few ideas of civilization, but apparently came to an unfortunate end before finishing the job. Thus the tribe no longer had a permanent chief; the chief's term was exactly one year. At the end of that time, they ate the current chief, and chose another chief. Their method of choosing a chief was the ``Eeny meeny miny mo'' method. All eligible tribal members (women were also eligible--one of the blessings of civilization the tribe had adopted) stood in a circle, a starting place was chosen, and the chief medicine man (who was ineligible for chieftainship) went around counting out `E', `e', `n', `y', `M', `e', `e', `n', `y', `M',`i', `n', `y', `M', `o!', `E', `e', `n', `y', `M', `e', `e', `n', `y', `M', `i', `n', `y', `M', `o!', .... At every `o!', the person indicated was pushed out of the circle which then closed up and the count restarted with his neighbor (the one who would have been `E' anyway). This process continued until only one was left--the new chief.

While the chance of glory for a year makes the job of chief highly attractive to tribal members, you (possessing a computer decades before they were invented) find the brevity of the glory unappealing. You have managed to find out that the count this year will start with Mxgobgwq (a very large person). You have also been busy doing a census, and know how many people are going to show up. Unfortunately, you do not know if the count will go to clockwise or counter-clockwise. You want to find out both locations that should not be choosen (you need to make sure not to stand in either of them).

Input

Input will consist of a series of lines, each line containing the number of people who will be present. You will always assume that Mxgobgwq is in the first location. You should stop processing when you encounter a 0 for number of people. The population will never be more than 500.

Output

Output will consist of a series of lines, one for each line of the input. Each line will consist of two numbers separated by at least one space. The first number will be the place to not stand when going clockwise. The second number will be where to not stand if the direction is counter-clockwise. You should always start numbering Mxgobgwq as 1 and number the people clockwise.

Sample input

2 
3
27 
150
0

Sample output

2 2
2 3
17 12
40 112



The statements and opinions included in these pages are those of the LSU Computer Science High School Programming Contest Staff only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.

© 2000 LSU Computer Science High School Programming Contest

This page last updated 2001/04/05 20:29:46.