#include<bits/stdc++.h>
using namespace std;
#define haisondeptraivippro signed
#define fi first
#define se second
#define int long long
#define ii pair<int ,int>
#define mp make_pair
map<int,int>d;
int j=0,n,b[100068],m,s[100068];
struct pt{
int d,c;
};
pt a[100068];
bool cmp(pt x,pt y){
return x.d<y.d;
}
haisondeptraivippro main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
int ans=0;
for(int i=1;i<=m;i++){
cin>>a[i].d>>a[i].c;
}
sort(a+1,a+m+1,cmp);
for(int i=1;i<=m;i++){
b[i]=a[i].d;
s[i]=s[i-1]+a[i].d;
// cout<<a[i].d<<" "<<a[i].c<<'\n';
}
for(int i=1;i<=m;i++){
int t=lower_bound(b+1,b+m+1,a[i].c)-b;
if(t<=m){
if(m-t+1>n)
t=m-n+1;
int check=0,kt=0;
if(t<=i){
check=a[t-1].d;
kt=a[i].d;
}
int p=a[i].d+s[m]-s[t-1]+(n-(m-t+1)-(kt==0))*a[i].c-kt;
// cout<<p<<" ";
if(check>0){
p+=check;
p-=a[i].d;
}
// cout<<t<<" "<<p<<" "<<check<<'\n';
ans=max(ans,max(p,a[i].d+(n-1)*a[i].c));
}
else
ans=max(ans,a[i].d+(n-1)*a[i].c);
}
cout<<ans;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBoYWlzb25kZXB0cmFpdmlwcHJvIHNpZ25lZAojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgc2Ugc2Vjb25kCiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGlpIHBhaXI8aW50ICxpbnQ+CiNkZWZpbmUgbXAgbWFrZV9wYWlyCm1hcDxpbnQsaW50PmQ7CmludCBqPTAsbixiWzEwMDA2OF0sbSxzWzEwMDA2OF07CnN0cnVjdCBwdHsKICAgIGludCBkLGM7Cn07CnB0IGFbMTAwMDY4XTsKYm9vbCBjbXAocHQgeCxwdCB5KXsKICAgIHJldHVybiB4LmQ8eS5kOwp9CiBoYWlzb25kZXB0cmFpdmlwcHJvIG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CiAgICBjb3V0LnRpZSgwKTsKICAgIGNpbj4+bj4+bTsKICAgIGludCBhbnM9MDsKICAgIGZvcihpbnQgaT0xO2k8PW07aSsrKXsKICAgICAgICBjaW4+PmFbaV0uZD4+YVtpXS5jOwogICAgfQogICAgc29ydChhKzEsYSttKzEsY21wKTsKICAgIGZvcihpbnQgaT0xO2k8PW07aSsrKXsKICAgICAgICBiW2ldPWFbaV0uZDsKICAgICAgICBzW2ldPXNbaS0xXSthW2ldLmQ7CiAgICAgICAvLyBjb3V0PDxhW2ldLmQ8PCIgIjw8YVtpXS5jPDwnXG4nOyAgICAgICAgCiAgICB9CiAgICBmb3IoaW50IGk9MTtpPD1tO2krKyl7CiAgICAgICAgaW50IHQ9bG93ZXJfYm91bmQoYisxLGIrbSsxLGFbaV0uYyktYjsKICAgICAgICBpZih0PD1tKXsKICAgICAgICAgICAgaWYobS10KzE+bikKICAgICAgICAgICAgICAgIHQ9bS1uKzE7CiAgICAgICAgICAgIGludCBjaGVjaz0wLGt0PTA7CiAgICAgICAgICAgIGlmKHQ8PWkpewogICAgICAgICAgICAgICAgY2hlY2s9YVt0LTFdLmQ7CiAgICAgICAgICAgICAgICBrdD1hW2ldLmQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaW50IHA9YVtpXS5kK3NbbV0tc1t0LTFdKyhuLShtLXQrMSktKGt0PT0wKSkqYVtpXS5jLWt0OwogICAgICAgICAvLyAgIGNvdXQ8PHA8PCIgIjsKICAgICAgICAgICAgaWYoY2hlY2s+MCl7CiAgICAgICAgICAgICAgICBwKz1jaGVjazsKICAgICAgICAgICAgICAgIHAtPWFbaV0uZDsKICAgICAgICAgICAgfQogICAgICAgICAvLyAgY291dDw8dDw8IiAiPDxwPDwiICI8PGNoZWNrPDwnXG4nOwogICAgICAgIGFucz1tYXgoYW5zLG1heChwLGFbaV0uZCsobi0xKSphW2ldLmMpKTsKICAgIH0KICAgIGVsc2UKICAgICAgICBhbnM9bWF4KGFucyxhW2ldLmQrKG4tMSkqYVtpXS5jKTsKICAgIH0KICAgIGNvdXQ8PGFuczsKfQo=