#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct SS
{
double a;
double b;
double c;
}S[1020];
bool cmp(SS A,SS B)
{
return A.c>B.c;
}
int main()
{
int m;
int n;
while(~scanf("%d %d",&m,&n))
{ if(m==-1&&n==-1)
break;
memset(S,0,sizeof(S));
double sum=0;
int i;
for(i=0;i<n;i++)
{scanf("%lf %lf",&S[i].a,&S[i].b);
S[i].c=S[i].a*1.0/S[i].b;
}
sort(S,S+n,cmp);
for(i=0;i<n;i++)
{
if(S[i].b>m)
{
break;
}
m-=S[i].b;
sum+=S[i].a;
}
if(i<=n-1)
sum+=m*S[i].a/S[i].b;
printf("%.3lf\n",sum);
}
}