Contest Print Server
In each case,the first line contains 5 integers n,s,x,y,mod (1<=n<=100, 1<=s,x,y,mod<=10007), and n lines of requests follow. The request is like "Team_Name request p pages" (p is integer, 0<p<=10007, the length of "Team_Name" is no longer than 20), means the team "Team_Name" need p pages to print, but for some un-know reason the printer will break down when the printed pages counter reached s(s is generated by the function s=(s*x+y)%mod ) and then the counter will become 0. In the same time the last request will be reprint from the very begin if it isn't complete yet(The data guaranteed that every request will be completed in some time).
You can get more from the sample.
Please note that you should print an empty line after each case.
2 3 7 5 6 177 Team1 request 1 pages Team2 request 5 pages Team3 request 1 pages 3 4 5 6 177 Team1 request 1 pages Team2 request 5 pages Team3 request 1 pages
1 pages for Team1 5 pages for Team2 1 pages for Team3 1 pages for Team1 3 pages for Team2 5 pages for Team2 1 pages for Team3