{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eXXX gets a new toy named Looploop. The toy has N elements arranged in a loop, an arrow pointing to one of the elements, and two preset parameters k1 and k2. Every element has a number on it.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/77eceb8de0ebca515289531117c7e121?v\u003d1726216318\"\u003e\u003c/center\u003e \u003cbr\u003e\u003cbr\u003eThe figure above shows a Looploop of 6 elments. Let\u0027s assuming the preset parameter k1 is 3, and k2 is 4.\u003cbr\u003eXXX can do six operations with the toy. \u003cbr\u003e\u003cbr\u003e1: add x \u003cbr\u003eStarting from the arrow pointed element, add x to the number on the clockwise first k2 elements.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/1bf0ecfd3a0f71999a50fe6c575313ae?v\u003d1726216318\"\u003e\u003c/center\u003e \u003cbr\u003e\u003cbr\u003e2: reverse\u003cbr\u003eStarting from the arrow pointed element, reverse the first k1 clockwise elements.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/05e2635b1373a394d1d2079ca5bc1cad?v\u003d1726216318\"\u003e\u003c/center\u003e \u003cbr\u003e\u003cbr\u003e3: insert x \u003cbr\u003eInsert a new element with number x to the right (along clockwise) of the arrow pointed element.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/05b00291c291984d28ec0d3a344e6556?v\u003d1726216318\"\u003e\u003c/center\u003e \u003cbr\u003e\u003cbr\u003e4: delete \u003cbr\u003eDelete the element the arrow pointed and then move the arrow to the right element.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/40016a6793056ff6e936913898f6c8c9?v\u003d1726216318\"\u003e\u003c/center\u003e \u003cbr\u003e\u003cbr\u003e5: move x \u003cbr\u003ex can only be 1 or 2. If x \u003d 1 , move the arrow to the left(along the counterclockwise) element, if x \u003d 2 move the arrow to the right element.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/af488d6d1b43a3a29a98713b422ae4d5?v\u003d1726216318\"\u003e\u003c/center\u003e \u003cbr\u003e\u003cbr\u003e6: query\u003cbr\u003eOutput the number on the arrow pointed element in one line.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/3472aba9b2f20ed55ef7ce8ac89ac638?v\u003d1726216318\"\u003e\u003c/center\u003e \u003cbr\u003e\u003cbr\u003eXXX wants to give answers to every query in a serial of operations.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are multiple test cases.\u003cbr\u003eFor each test case the first line contains N,M,k1,k2(2≤k1\u0026lt;k2≤N≤10\u003csup\u003e5\u003c/sup\u003e, M≤10\u003csup\u003e5\u003c/sup\u003e) indicating the initial number of elements, the total number of operations XXX will do and the two preset parameters of the toy. \u003cbr\u003eSecond line contains N integers ai(-10\u003csup\u003e4\u003c/sup\u003e≤ai≤10\u003csup\u003e4\u003c/sup\u003e) representing the N numbers on the elements in Looploop along clockwise direction. The arrow points to first element in input at the beginning. \u003cbr\u003eThen m lines follow, each line contains one of the six operations described above.\u003cbr\u003eIt is guaranteed that the \"x\" in the \"add\",\"insert\" and \"move\" operations is always integer and its absolute value ≤104. The number of elements will never be less than N during the operations. \u003cbr\u003eThe input ends with a line of 0 0 0 0."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output case number in the first line(formatted as the sample output). Then for each query in the case, output the number on the arrow pointed element in a single line."}},{"title":"Sample","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\u003e5 1 2 4\r\n3 4 5 6 7\r\nquery\r\n5 13 2 4\r\n1 2 3 4 5\r\nmove 2\r\nquery\r\ninsert 8\r\nreverse\r\nquery\r\nadd 2\r\nquery\r\nmove 1\r\nquery\r\nmove 1\r\nquery\r\ndelete\r\nquery\r\n0 0 0 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n3\r\nCase #2:\r\n2\r\n8\r\n10\r\n1\r\n5\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}