#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bitset>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef std::vector<int> vi;
typedef std::vector<pair<int, int> > vii;
//----------Main source code -----------------//
float d, cap, mpg, icost, sd[54], p[54], fuel, ans;
int n;
void rcr(int i){
float tfuel =fuel, tcost = icost;
fuel -= (sd[i]-sd[i-1])/mpg;
if(fuel>0){
//----end------//
if(i==n+1){
if(icost<ans) ans=icost;
fuel=tfuel;
icost=tcost;
return;
}
//Skips this station
rcr(i+1);
//or fuel up here
icost+= floor(p[i]*(cap-fuel)+0.5)+200;
fuel=cap;
if(icost<ans)
rcr(i+1);
}
fuel=tfuel;
icost=tcost;
}
int main() {
int t=1;
while(cin>>d&&d>=0){
cin>>cap>>mpg>>icost>>n;
for(int i=1;i<=n;i++) cin>>sd[i]>>p[i];
sd[n+1]=d;
p[n+1]=sd[0]=0;
fuel=cap;
ans = 999999999;
icost*=100;
rcr(1);
printf("Data Set #%d\nminimum cost = $%.2f\n",t++, ans/100);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Yml0c2V0PgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPG1hdGguaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBzdGQ6OnZlY3RvcjxpbnQ+IHZpOwp0eXBlZGVmIHN0ZDo6dmVjdG9yPHBhaXI8aW50LCBpbnQ+ID4gdmlpOwovLy0tLS0tLS0tLS1NYWluIHNvdXJjZSBjb2RlIC0tLS0tLS0tLS0tLS0tLS0tLy8KZmxvYXQgZCwgY2FwLCBtcGcsIGljb3N0LCBzZFs1NF0sIHBbNTRdLCBmdWVsLCBhbnM7CmludCBuOwp2b2lkIHJjcihpbnQgaSl7CglmbG9hdCB0ZnVlbCA9ZnVlbCwgd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