{"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\"\u003eThe Mid-Autumn Festival, also known as the Moon Festival or Zhongqiu Festival is a popular harvest festival celebrated by Chinese people, dating back over 3,000 years to moon worship in China\u0027s Shang Dynasty. The Zhongqiu Festival is held on the 15th day of the eighth month in the Chinese calendar, which is in September or early October in the Gregorian calendar. It is a date that parallels the autumnal equinox of the solar calendar, when the moon is at its fullest and roundest. \u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/b8b2cdfc51173a4ef189c2792d9d753f?v\u003d1715563398\"\u003e\u003c/center\u003e \u003cbr\u003eThe traditional food of this festival is the mooncake. Chinese family members and friends will gather to admire the bright mid-autumn harvest moon, and eat mooncakes under the moon together. In Chinese, “round”(圆) also means something like “faultless” or “reuion”, so the roundest moon, and the round mooncakes make the Zhongqiu Festival a day of family reunion.\u003cbr\u003e\u003cbr\u003eAlice has opened up a 24-hour mooncake shop. She always gets a lot of orders. Only when the time is K o’clock sharp( K \u003d 0,1,2 …. 23) she can make mooncakes, and We assume that making cakes takes no time. Due to the fluctuation of the price of the ingredients, the cost of a mooncake varies from hour to hour. She can make mooncakes when the order comes,or she can make mooncakes earlier than needed and store them in a fridge. The cost to store a mooncake for an hour is S and the storage life of a mooncake is T hours. She now asks you for help to work out a plan to minimize the cost to fulfill the orders.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains no more than 10 test cases. \u003cbr\u003eFor each test case:\u003cbr\u003eThe first line includes two integers N and M. N is the total number of orders. M is the number of hours the shop opens. \u003cbr\u003eThe next N lines describe all the orders. Each line is in the following format:\u003cbr\u003e\u003cbr\u003emonth date year H R\u003cbr\u003e\u003cbr\u003eIt means that on a certain date, a customer orders R mooncakes at H o’clock. “month” is in the format of abbreviation, so it could be \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\" or \"Dec\". H and R are all integers. \u003cbr\u003eAll the orders are sorted by the time in increasing order. \u003cbr\u003eThe next line contains T and S meaning that the storage life of a mooncake is T hours and the cost to store a mooncake for an hour is S.\u003cbr\u003eFinally, M lines follow. Among those M lines, the i\u003csup\u003eth\u003c/sup\u003e line( i starts from 1) contains a integer indicating the cost to make a mooncake during the i\u003csup\u003eth\u003c/sup\u003e hour . The cost is no more than 10000. Jan 1st 2000 0 o\u0027clock belongs to the 1\u003csup\u003est\u003c/sup\u003e hour, Jan 1st 2000 1 o\u0027clock belongs to the 2\u003csup\u003end\u003c/sup\u003e hour, …… and so on.\u003cbr\u003e\u003cbr\u003e(0\u0026lt;N \u0026lt;\u003d 2500; 0 \u0026lt; M,T \u0026lt;\u003d100000; 0\u0026lt;\u003dS \u0026lt;\u003d 200; R\u0026lt;\u003d10000 ; 0\u0026lt;\u003dH\u0026lt;24)\u003cbr\u003e\u003cbr\u003eThe input ends with N \u003d 0 and M \u003d 0."}},{"title":"Output","value":{"format":"HTML","content":"You should output one line for each test case: the minimum cost. \u003cbr\u003e"}},{"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\u003e1 10\r\nJan 1 2000 9 10\r\n5 2\r\n20 \r\n20 \r\n20 \r\n10 \r\n10\r\n8\r\n7 \r\n9 \r\n5 \r\n10\r\n0 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e70\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003e“Jan 1 2000 9 10” means in Jan 1st 2000 at 9 o\u0027clock , there\u0027s a consumer ordering 10 mooncakes. \u003cbr\u003eMaybe you should use 64-bit signed integers. The answer will fit into a 64-bit signed integer.\u003cbr\u003e"}}]}