UVA407 Gears on a Board

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=348 [PDF](https://uva.onlinejudge.org/external/4/p407.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA407/c2ad743e59ef71cc4db40c0654e9c875e8f9113a.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA407/7461b4b7a580652ee6d46e7d817998db8116c3f9.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA407/30492785a9fb62aa3491b867cb2a5cb2ca2b882d.png)