1009
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cfloat>
using namespace std;
struct ppp {
double k, j, f;
};
bool kk(ppp a,ppp b){
return a.k > b.k;
}
int main()
{
int n;
double m;
while (cin >> m >> n&&(m!=-1&&n!=-1)) {
ppp Fat[1010] = { 0 };
for (int i = 0;i < n;i++) {
cin >> Fat[i].j >> Fat[i].f;
Fat[i].k = Fat[i].j / Fat[i].f;
}
sort(Fat, Fat + n, kk);
double d = m;
double num = 0;
for (int i = 0;d>=0;i++) {
if (d >= Fat[i].f) {
d -= Fat[i].f;
if (Fat[i].j == 0) {
d = -1;
}
num += Fat[i].j;
}
else {
num += d*Fat[i].k;
d = -1;
}
}
printf("%.3lf\n", num);
}
return 0;
}