Legolas and Gimli are packing rations before they leave the Woodland Realm, and the kitchen has badly underestimated the belly of a dwarf. Gimli refuses to take a step until his pack holds as many calories as it can.
The kitchen has M kinds of food. Each kind has a volume per serving and a calorie count per serving. Gimli can order any number of servings of a kind, including none. Choose how many servings of each food to order so that the total volume fits in the space left in the pack and the total calorie count is as large as possible.
Several orders can reach the same largest calorie count. In that case the answer is the one whose sequence of quantities comes first in lexicographic order: order as few servings as possible of the first food, then, under that condition, as few servings as possible of the second food, and so on.
The input holds several test cases. The first line of a test case has one integer C, the space left in Gimli's pack in cubic centimeters. The second line has one integer M, the number of foods on offer. Each of the next M lines has two integers, the volume vi of one serving in cubic centimeters and its calorie count ci. These lines are given in non-decreasing order of volume.
A test case whose first line is 0 marks the end of the input, and it produces no output.
1≤C≤10000, 1≤M≤20, 1≤vi≤10000, 0≤ci≤100000, and v1≤v2≤⋯≤vM. At most 10 test cases come before the terminating 0.
For each test case, print one line with M integers separated by single spaces. The i-th integer is the number of servings of the i-th food that Gimli should order.
When several orders reach the largest calorie count, print the sequence of quantities that comes first in lexicographic order.