Yet another Number Sequence

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=18&page=show_problem&problem=1630 [PDF](https://uva.onlinejudge.org/external/106/p10689.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10689/768cfa40afe728dcfd1391737187a05d67a72359.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10689/8cf2cc8b0bca94f35431b74ac887634edabfeb31.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10689/7a8b68ad8785d2b43609a0d58390ccc513ae3613.png)

输入输出样例

输入样例 #1

4
0 1 11 3
0 1 42 4
0 1 22 4
0 1 21 4

输出样例 #1

89
4296
7711
946