{"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\u003eEverybody knows that Balázs has the fanciest fence in the whole town. It\u0027s built up from $$$N$$$ fancy sections. The sections are rectangles standing closely next to each other on the ground. The $$$i$$$th section has integer height $$$h_i$$$ and integer width $$$w_i$$$. We are looking for fancy rectangles on this fancy fence. A rectangle is fancy if: \u003c/p\u003e\u003cul\u003e \u003cli\u003e its sides are either horizontal or vertical and have integer lengths \u003c/li\u003e\u003cli\u003e the distance between the rectangle and the ground is integer \u003c/li\u003e\u003cli\u003e the distance between the rectangle and the left side of the first section is integer \u003c/li\u003e\u003cli\u003e it\u0027s lying completely on sections \u003c/li\u003e\u003c/ul\u003e What is the number of fancy rectangles? This number can be very big, so we are interested in it modulo $$$10^9+7$$$."}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains $$$N$$$ ($$$1\\leq N \\leq 10^{5}$$$) – the number of sections. The second line contains $$$N$$$ space-separated integers, the $$$i$$$th number is $$$h_i$$$ ($$$1 \\leq h_i \\leq 10^{9}$$$). The third line contains $$$N$$$ space-separated integers, the $$$i$$$th number is $$$w_i$$$ ($$$1 \\leq w_i \\leq 10^{9}$$$).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eYou should print a single integer, the number of fancy rectangles modulo $$$10^9+7$$$. So the output range is $$$0,1,2,\\ldots, 10^9+6$$$.\u003c/p\u003e"}},{"title":"Scoring","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":"Examples","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\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eThe fence looks like this: \u003cimg class\u003d\"tex-graphics\" height\u003d\"189px\" src\u003d\"CDN_BASE_URL/ca6105cda1b7c42b37838b58bb4351bb?v\u003d1726730221\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003eThere are 5 fancy rectangles of shape: \u003cimg class\u003d\"tex-graphics\" height\u003d\"49px\" src\u003d\"CDN_BASE_URL/eaba93f60851364ed81349343e679f40?v\u003d1726730221\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003eThere are 3 fancy rectangles of shape: \u003cimg class\u003d\"tex-graphics\" height\u003d\"49px\" src\u003d\"CDN_BASE_URL/4d96e7090d14334471bc7b5068af0f60?v\u003d1726730221\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003eThere is 1 fancy rectangle of shape: \u003cimg class\u003d\"tex-graphics\" height\u003d\"49px\" src\u003d\"CDN_BASE_URL/818b2325e153aea2367f37524684d95c?v\u003d1726730221\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003eThere are 2 fancy rectangles of shape: \u003cimg class\u003d\"tex-graphics\" height\u003d\"76px\" src\u003d\"CDN_BASE_URL/542977c2838afffe4f35a346ea3dc1f3?v\u003d1726730221\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003eThere is 1 fancy rectangle of shape: \u003cimg class\u003d\"tex-graphics\" height\u003d\"76px\" src\u003d\"CDN_BASE_URL/c1190a16f23a7cf87d2e821d2069fcff?v\u003d1726730221\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e"}}]}