2 import java
.util
.Scanner
;
4 public class business_mb
implements Runnable
{
5 public static void main(String
[] args
) {
6 new Thread(new business_mb()).start();
11 final Scanner in
= new Scanner(new FileReader("business.in"));
12 final PrintWriter out
= new PrintWriter("business.out");
14 final int n
= in
.nextInt();
15 final int m
= in
.nextInt();
17 int ans
= Integer
.MAX_VALUE
;
18 for (int i
= 0; i
< m
; i
++) {
19 final int u
= in
.nextInt();
20 final int d
= in
.nextInt();
21 final int x
= (n
* d
) / (u
+ d
) + 1;
22 final int cur
= x
* (u
+ d
) - n
* d
;
23 ans
= Math
.min(ans
, cur
);
30 } catch (IOException e
) {