#include <stdio.h>
#include <stdlib.h>
typedef struct goods{
double weigh;
double value;
double rate;
}GOODS;
int cmp(const void *a,const void *b)
{
GOODS *g1=(GOODS *)a;
GOODS *g2=(GOODS *)b;
double temp=g2->rate-g1->rate;
if(temp>0)return 1;
else if(temp<0)return -1;
else return 0;
}
void main()
{
double m;
int n;
while(scanf("%lf%d",&m,&n))
{
int i;
int index=0;
double ans=0;
GOODS buf[1000];
if(m==-1&&n==-1)break;
for(i=0;i<n;i++)
{
scanf("%lf%lf",&buf[i].weigh,&buf[i].value);
buf[i].rate=buf[i].weigh/buf[i].value;
}
qsort(buf,n,sizeof(GOODS),cmp);
while(m>0&&index<n)
{
if(m>buf[index].value)
{
ans+=buf[index].weigh;
m-=buf[index].value;
}
else{
ans+=buf[index].weigh*m/buf[index].value;
m=0;
}
index++;
}
printf("%.3lf\n",ans);//结果保留三位小数
}
}
f