Annoyed Coworkers

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

A picture of you, not working. Source: XKCD 303

It's another day in the office, and you're a mastermind of not doing any work yourself. Instead, you'll go to your coworkers for "help," but secretly have them do all the work.

You've determined that the more one of your coworkers helps you, the more annoyed they become. You've also been able to determine how much more annoyed a coworker gets everytime you ask them for help. At the beginning of the day, a coworker is initially aa annoyed at you. That's their annoyance level. Everytime you ask them for help though, they become dd more annoyed at you -- their annoyance level aa increases by a constant amount dd so that a=a+da=a+d.

You want to complete a project of hh tasks solely with "help" from your coworkers, but you need to be careful not to annoy any of them too much.

What's the best you can do?

입력

The first line contains 22 integers hh and cc, where hh (1h100,0001 \le h \le 100\\,000) is the number of times you have to ask for help to complete the project, and cc (1c100,0001 \le c \le 100\\,000) denotes the number of coworkers you have.

Each of the following cc lines contains two positive integers aa and dd, representing a coworker whose initial annoyance level is aa and who is getting more annoyed at you by an increase of dd every time you ask them for help (1a,d1091\le a, d \le 10^9).

출력

Output a single number, which is the maximum annoyance level any coworker has at you provided you use an optimal strategy to minimize this level. (In other words, of all possible strategies, choose one that minimizes the annoyance level of the worker or workers who are most annoyed at you at the end.)