Not an official ACM page
[Problem C | 1994 Western European Regional problem set | My ACM problem archive | my home page]

1994-1995 ACM International Collegiate Programming Contest
Western European Regional

Problem B


In some far away land, the death penalty is still in force. The king of the land, who likes to think that he is a nice chap, has made the execution of the prisoners part of the yearly Games. At the end of the Games, all the prisoners from death row are put in a circle in the arena. One of the prisoners is designated number 1. Then the executioner takes position at the center of the circle, and starts reciting a rhyme he remembers from his childhood: 'IENE MIENE MINI NOO, I THINK FOR YOU IT IS TIME TO GO'. For each syllable of the rhyme he aims at a different person, starting with prisoner 1 for 'IENE', prisoner 2 for 'MIENE', etc. (thus with each syllable he moves his aim to the right.) The prisoner he aims at with 'GO' is then shot, and, during the cheers of the crowd, removed from the scene. At the next reciting of the rhyme, the executioner starts at the rightmost neighbor of the most recently deceased.

The king (I told you he is a nice chap), releases the one prisoner left standing at the end of the game.

If you would ever 'participate' in this game, you might want to improve your chances by determining beforehand who is going to be released. To be able to calculate that, you need to know the number of prisoners, and the length in syllables of the rhyme used by the executioner for this particular game. It might be nice to have a program which calulates this quickly for you.

Input Specification

The first line of input contains a single integer N , specifying the number of test cases. Then follow N lines, one per test case, containing two integers, P and S, where P is the number of prisoners (1 <= P <= 1 000) and S is the number of syllables in the rhyme (1 <= S <= 10,000).

Output Specification

For each test case print the following text: 'With P prisoners and S syllables, I'd like to be number X.', where X is the prisoner index of the one surviving (the prisoners are numbered from 1 through P in the direction of the aim of the executioner).

Example Input

3 3
6 2
10 1

Example Output

With 3 prisoners and 3 syllables, I'd like to be number 2.
With 6 prisoners and 2 syllables, I'd like to be number 5.
With 10 prisoners and 1 syllables, I'd like to be number 10.

This page maintained by Ed Karrels.
Last updated September 20, 1999