UVA367 Halting Factor Replacement Systems

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=303 [PDF](https://uva.onlinejudge.org/external/3/p367.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA367/877fd461b0a9eb6a90cf07ed73d294217a385ddc.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA367/38943d7df7fc153110f822e5c25cc6bc07a3478e.png)

Output Format

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