{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eThere is an infinitely long street that runs west to east, which we consider as a number line.\u003c/p\u003e\r\n\u003cp\u003eThere are \u003cvar\u003e\\(N\\)\u003c/var\u003e roadworks scheduled on this street.\r\nThe \u003cvar\u003e\\(i\\)\u003c/var\u003e-th roadwork blocks the point at coordinate \u003cvar\u003e\\(X_i\\)\u003c/var\u003e from time \u003cvar\u003e\\(S_i - 0.5\\)\u003c/var\u003e to time \u003cvar\u003e\\(T_i - 0.5\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003e\u003cvar\u003e\\(Q\\)\u003c/var\u003e people are standing at coordinate \u003cvar\u003e\\(0\\)\u003c/var\u003e. The \u003cvar\u003e\\(i\\)\u003c/var\u003e-th person will start the coordinate \u003cvar\u003e\\(0\\)\u003c/var\u003e at time \u003cvar\u003e\\(D_i\\)\u003c/var\u003e, continue to walk with speed \u003cvar\u003e\\(1\\)\u003c/var\u003e in the positive direction and stop walking when reaching a blocked point.\u003c/p\u003e\r\n\u003cp\u003eFind the distance each of the \u003cvar\u003e\\(Q\\)\u003c/var\u003e people will walk.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eAll values in input are integers.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq N, Q \\leq 2 \\times 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(0 \\leq S_i \u0026lt; T_i \\leq 10^9\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq X_i \\leq 10^9\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(0 \\leq D_1 \u0026lt; D_2 \u0026lt; ... \u0026lt; D_Q \\leq 10^9\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eIf \u003cvar\u003e\\(i \\neq j\\)\u003c/var\u003e and \u003cvar\u003e\\(X_i \u003d X_j\\)\u003c/var\u003e, the intervals \u003cvar\u003e\\([S_i, T_i)\\)\u003c/var\u003e and \u003cvar\u003e\\([S_j, T_j)\\)\u003c/var\u003e do not overlap.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e \u003cvar\u003e\\(Q\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_1\\)\u003c/var\u003e \u003cvar\u003e\\(T_1\\)\u003c/var\u003e \u003cvar\u003e\\(X_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(:\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_N\\)\u003c/var\u003e \u003cvar\u003e\\(T_N\\)\u003c/var\u003e \u003cvar\u003e\\(X_N\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(D_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(:\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(D_Q\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003ePrint \u003cvar\u003e\\(Q\\)\u003c/var\u003e lines. The \u003cvar\u003e\\(i\\)\u003c/var\u003e-th line should contain the distance the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th person will walk or \u003cvar\u003e\\(-1\\)\u003c/var\u003e if that person walks forever.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 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\u003e4 6\r\n1 3 2\r\n7 13 10\r\n18 20 13\r\n3 4 2\r\n0\r\n1\r\n2\r\n3\r\n5\r\n8\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n2\r\n10\r\n-1\r\n13\r\n-1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eThe first person starts coordinate \u003cvar\u003e\\(0\\)\u003c/var\u003e at time \u003cvar\u003e\\(0\\)\u003c/var\u003e and stops walking at coordinate \u003cvar\u003e\\(2\\)\u003c/var\u003e when reaching a point blocked by the first roadwork at time \u003cvar\u003e\\(2\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eThe second person starts coordinate \u003cvar\u003e\\(0\\)\u003c/var\u003e at time \u003cvar\u003e\\(1\\)\u003c/var\u003e and reaches coordinate \u003cvar\u003e\\(2\\)\u003c/var\u003e at time \u003cvar\u003e\\(3\\)\u003c/var\u003e. The first roadwork has ended, but the fourth roadwork has begun, so this person also stops walking at coordinate \u003cvar\u003e\\(2\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eThe fourth and sixth persons encounter no roadworks while walking, so they walk forever. The output for these cases is \u003cvar\u003e\\(-1\\)\u003c/var\u003e.\u003c/p\u003e\u003c/section\u003e\r\n"}}]}