/* package whatever; // don't place package name! */
import java.io.*;
import java.util.*;
/* Name of the class has to be "Main" only if the class is public. */
class LoansomeCarBuyer
{
public static void main
(String[] args
) {
// Input
Scanner scanner
= new Scanner
(System.
in); int term = scanner.nextInt();
while (term >= 0) {
double downPayment = scanner.nextDouble();
double loan = scanner.nextDouble();
double initialValue = downPayment + loan;
double payment;
if (term != 0) {
payment = loan / term;
} else {
payment = loan;
}
int numRecords = scanner.nextInt();
int[] months = new int[numRecords];
double[] values = new double[numRecords];
for (int i = 0; i < numRecords; i++) {
months[i] = scanner.nextInt();
values[i] = scanner.nextDouble();
}
// Calculation.
double prev = values[0];
double currentValue = initialValue - initialValue * prev;
double owe = loan;
int currentMonth;
if (currentValue > owe) {
currentMonth = 0;
} else {
int i = 1;
currentMonth = 1;
while (true) {
if (i < numRecords && currentMonth == months[i]) {
prev = values[i];
i++;
}
currentValue = currentValue - currentValue * prev;
owe -= payment;
if (currentValue > owe) break;
currentMonth++;
}
}
if (currentMonth == 1) {
System.
out.
println(currentMonth
+ " month"); } else {
System.
out.
println(currentMonth
+ " months"); }
term = scanner.nextInt();
}
scanner.close();
}
}