Alphabet Soup

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=278&page=show_problem&problem=3809 [PDF](https://uva.onlinejudge.org/external/123/p12387.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12387/047b5ae41158ef349c305448e05d1b8d80d7c381.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12387/461a268ee9510b73931aecd3e523329dfd88f53e.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12387/a33577ab37e1f9e1fe01a4590a049bb98b00d401.png)

输入输出样例

输入样例 #1

2 4
0
90000
180000
270000
100 5
0
45000
90000
180000
270000
-1 -1

输出样例 #1

6
99999307