{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e大家都知道,巴拉兹家的篱笆是全镇最华丽的。它由$$$N$$$个华丽的部分构成。这些部分是紧密站立在地面上的矩形。第$$$i$$$部分的高度是整数$$$h_i$$$,宽度是整数$$$w_i$$$。我们正在寻找这个华丽篱笆上的华丽矩形。如果一个矩形是华丽的,那么它满足以下条件:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e它的边要么是水平的,要么是垂直的,并且长度是整数\u003c/li\u003e\n\u003cli\u003e矩形与地面的距离是整数\u003c/li\u003e\n\u003cli\u003e矩形与第一个部分的左侧的距离是整数\u003c/li\u003e\n\u003cli\u003e它完全位于部分上\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e华丽矩形的数量是多少?这个数字可能非常大,所以我们对它取模$$$10^9+7$$$。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含$$$N$$$($$$1\\leq N \\leq 10^{5}$$$)- 部分的数量。第二行包含$$$N$$$个用空格分隔的整数,第$$$i$$$个数字是$$$h_i$$$($$$1 \\leq h_i \\leq 10^{9}$$$)。第三行包含$$$N$$$个用空格分隔的整数,第$$$i$$$个数字是$$$w_i$$$($$$1 \\leq w_i \\leq 10^{9}$$$)。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e你应该打印一个整数,即华丽矩形的数量模$$$10^9+7$$$。因此输出范围是$$$0,1,2,\\ldots, 10^9+6$$$。\u003c/p\u003e"}},{"title":"评分","value":{"format":"HTML","content":"\u003ccenter\u003e$$$ \\begin{array}{|c|c|c|} \\hline \\text{Subtask} \u0026amp; \\text{Points} \u0026amp; \\text{Constraints} \\\\ \\hline 1 \u0026amp; 0 \u0026amp; \\text{sample}\\\\ \\hline 2 \u0026amp; 12 \u0026amp; N \\leq 50 \\: \\text{and} \\: h_i \\leq 50 \\: \\text{and} \\: w_i \u003d 1 \\: \\text{for all} \\: i \\\\ \\hline 3 \u0026amp; 13 \u0026amp; h_i \u003d 1 \\: \\text{or} \\: h_i \u003d 2 \\: \\text{for all} \\: i \\\\ \\hline 4 \u0026amp; 15 \u0026amp; \\text{all} \\: h_i \\: \\text{are equal} \\\\ \\hline 5 \u0026amp; 15 \u0026amp; h_i \\leq h_{i+1} \\: \\text{for all} \\: i \\leq N-1 \\\\ \\hline 6 \u0026amp; 18 \u0026amp; N \\leq 1000\\\\ \\hline 7 \u0026amp; 27 \u0026amp; \\text{no additional constraints}\\\\ \\hline \\end{array} $$$\u003c/center\u003e"}},{"title":"示例1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n1 2\n1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e12\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e篱笆看起来是这样的:\u003cimg class\u003d\"tex-graphics\" height\u003d\"189px\" src\u003d\"CDN_BASE_URL/ca6105cda1b7c42b37838b58bb4351bb?v\u003d1702114024\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003e有5个形状的华丽矩形:\u003cimg class\u003d\"tex-graphics\" height\u003d\"49px\" src\u003d\"CDN_BASE_URL/eaba93f60851364ed81349343e679f40?v\u003d1702114024\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003e有3个形状的华丽矩形:\u003cimg class\u003d\"tex-graphics\" height\u003d\"49px\" src\u003d\"CDN_BASE_URL/4d96e7090d14334471bc7b5068af0f60?v\u003d1702114024\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003e有1个形状的华丽矩形:\u003cimg class\u003d\"tex-graphics\" height\u003d\"49px\" src\u003d\"CDN_BASE_URL/818b2325e153aea2367f37524684d95c?v\u003d1702114024\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003e有2个形状的华丽矩形:\u003cimg class\u003d\"tex-graphics\" height\u003d\"76px\" src\u003d\"CDN_BASE_URL/542977c2838afffe4f35a346ea3dc1f3?v\u003d1702114024\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003e有1个形状的华丽矩形:\u003cimg class\u003d\"tex-graphics\" height\u003d\"76px\" src\u003d\"CDN_BASE_URL/c1190a16f23a7cf87d2e821d2069fcff?v\u003d1702114024\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e"}}]}