#include<iostream> #include<iomanip> using namespace std; double a[1000]; double b[1000]; double c[1000]; int main() { int m,n,i,j; while((cin >> m >> n) && (m != -1 && n != -1)) { double sum = 0.0; for( i = 0; i < n; i++) { cin >> a[i] >> b[i]; c[i] = a[i]/b[i]; } for( i = 0; i < n; i++) for( j = 0; j < n-i-1; j++) { if(c[j] < c[j+1]) { double temp; temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; temp = b[j]; b[j] = b[j+1]; b[j+1] = temp; temp = c[j]; c[j] = c[j+1]; c[j+1] = temp; } } for( i = 0; i < n; i++) { if (m >= b[i]) { sum += a[i]; m -= b[i]; } else { sum += a[i] * (double)m / b[i]; break; } } cout << setiosflags(ios::fixed) << setprecision(3) << sum << endl; } return 0; }