#include
int main(){
int m,i,j,k;
double rate,sum,ji,fi,t,n; // double型数据
while(scanf("%lf%d",&n,&m)!=EOF&&n+1||m+1){// 一直读到文件为用EOF
k=3*m,sum=0;
double a[k];// double型数据
for(i=0;i
scanf("%lf%lf",&ji,&fi);
rate=ji/fi;
a[i]=rate,a[i+1]=ji,a[i+2]=fi;
}
for(i=0;i
for(j=i+3;j
if(a[i]
t=a[i],a[i]=a[j],a[j]=t;
t=a[i+1],a[i+1]=a[j+1],a[j+1]=t;
t=a[i+2],a[i+2]=a[j+2],a[j+2]=t;
}
//for(i=0;i
//printf("%.2f ",a[i]);
for(i=0;i
if(a[i+2]<=n)sum+=a[i+1],n-=a[i+2];
else{ sum+=n*a[i];break;}
}
printf("%.3fn",sum);
}
}