logo AlgoBeat OnlineJudge
登录 注册

#215376. [SWERC 2017] Shattered Cake

内存限制:1024 MiB 时间限制:10000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A rectangular cake is transported via a truck to a restaurant. On the way to the destination, the truck hits a pothole, which shatters the cake in perfectly rectangular pieces of width and length , for .

At the destination, the damage is assessed, and the customer decides to order a replacement cake of the same dimensions. Unfortunately, the original order form was incompletely filled and only the width of the cake is known. The restaurant asks for your help to find out the length of the cake. Fortunately, all pieces of the shattered cake have been kept.

输入格式

The input consists of the following integers:

  • on the first line, the width of the cake;
  • on the second line, the number of shattered pieces;
  • on each of the next lines, the width and length of each piece.

输出格式

The output should be the integer .

样例

样例输入 1

4
7
2 3
1 4
1 2
1 2
2 2
2 2
2 1

样例输出 1

6

数据范围与提示

Limits

  • ;
  • ;
  • for each , .