Олимпиадный тренинг

Задача 38384. The choice of flowers for the bouquet


Volodya wants to beautifully congratulate his wife on their wedding anniversary and is going to give her a bouquet of n flowers.

Arriving at a flower shop, Volodya discovered that a bouquet can be made from flowers of m different types, and the number of flowers of each type is not limited. Volodya knows that the first flower of the i-th species in the bouquet makes his wife happier by ai, and each next flower  
this way she becomes happier on bi. That is, if in the bouquet xi > 0 flowers of type i, then flowers of this type make Volodya's wife happier by ai + (xi − 1) · bi.

Like any loving husband, Volodya wants to please his wife as much as possible. Therefore he wants to know by what maximum amount her happiness can increase from a bouquet, picked from the flowers available in the store.

Input data format
The first line contains two integers n and m (1 ≤ n ≤ 109 , 1 ≤ m ≤ 100 000) — required 
the number of flowers in the bouquet and the number of flowers available.
Each of the following m lines describes the i-th kind of flowers and contains two integers ai and bi (0 ≤ ai  , bi ≤ 109 ) — an increase in happiness from the first flower of the i-th species and an increase in happiness from each subsequent flower of this species.

Output data format
In a single line print a single number — the maximum increase in happiness that Volodya's wife can get from a bouquet of n flowers.
 
Examples
# Input Output
1 4 3
50
14
2 2
14
2 5 3
5 2
4 2
3 1
16