Alice's mooncake shop
Mid-Autumn Festival，意味高商的中间时代节日。也足以依赖八月节的任何特色称呼，比如Moon Festival对应的为光明的月的记念日、Mooncake Festival意味月饼节。随着国内知识的震慑浓厚，也会有那些土耳其共和国语直接英译为保加利亚共和国语，因而八月节也得以称之为Zhongqiu Festival。
The Mid-Autumn Festival is a time for Chinese people all over the world to come together, eat special cakes and gaze at the full moon。中拜月节是八个国内外的中国人和妻孥聚在同盟吃月饼、赏明亮的月的回想日。
The 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's 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.
八月节向往足以这么说：Happy Mid-Autumn Day!
I wish you a happy Mid-Autumn Day!
happy Mid-Autumn Festival to the friends and relatives by my side.
On the Mid-Autumn Day, may your life always be filled with happy times and may all your wishes come true. Happy Mid-Autumn Day!
Wish us a long life to share the beauty of this graceful moonlight, even thousands miles apart.
A bright moon and stars twinkle and shine. Wishing you a merry mid-autumn day and a happy life.
On the night with blooming flowers and a full moon, I want to express my best wishes and blessings. May you have a sweet dream!
Though a happy occasion, there's a heartbreaking story that explains how it came to be。即使那是三个兴奋的纪念日，但那背后却持有一段令人心碎的传说。
The 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.
"Zhong Qiu Jie", which is also known as the Mid-Autumn Festival, is celebrated on the 15th day of the 8th month of the lunar calendar. It is a time for family members and loved ones to congregate and enjoy the full moon - an auspicious symbol of abundance, harmony and luck. Adults will usually indulge in fragrant mooncakes of many varieties with a good cup of piping hot Chinese tea, while the little ones run around with their brightly-lit lanterns.
"Zhong Qiu Jie" probably began as a harvest festival. The festival was later given a mythological flavour with legends of Chang-E, the beautiful lady in the moon.
According to Chinese mythology, the earth once had 10 suns circling over it. One day, all 10 suns appeared together, scorching the earth with their heat. The earth was saved when a strong archer, Hou Yi, succeeded in shooting down 9 of the suns. Yi stole the elixir of life to save the people from his tyrannical rule, but his wife, Chang-E drank it. Thus started the legend of the lady in the moon to whom young Chinese girls would pray at the Mid-Autumn Festival.
In the 14th century, the eating of mooncakes at "Zhong Qiu Jie" was given a new significance. The story goes that when Zhu Yuan Zhang was plotting to overthrow the Yuan Dynasty started by the Mongolians, the rebels hid their messages in the Mid-Autumn mooncakes. Zhong Qiu Jie is hence also a commemoration of the overthrow of the Mongolians by the Han people.
During the Yuan Dynasty China was ruled by the Mongolian people. Leaders from the preceding Sung Dynasty were unhappy at submitting to foreign rule, and set how to coordinate the rebellion without it being discovered. The leaders of the rebellion, knowing that the Moon Festival was drawing near, ordered the making of special cakes. Packed into each mooncake was a message with the outline of the attack. On the night of the Moon Festival, the rebels successfully attacked and overthrew the government. What followed was the establishment of the Ming Dynasty . Today, moon cakes are eaten to commemorate this event.
Chinese legend tells of the hero Houyi and his beautiful wife Chang'e。在中华夏族民共和国的轶事中，有位勇猛叫做后羿，他有个雅观的妻妾名为常娥。
Alice 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 = 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.
In ancient times the "On the eve of Autumn Twilight" practices. On the eve of that worship Goddess. Set large incense table, put the moon cake, watermelons, apples, dates, plums, grapes other offerings, moon cake and watermelon is definitely not small. Also cut into the lotus-shaped watermelon. Under the month, the moon god on the moon that direction, Candle high burning the whole family followed by worship the moon, then the charge of the housewife cut happy moon cake. Pre-cut people who count the number of good family, at home, in the field should count together, can not cut more and no cut less the same size.
On that day people usually go back home to have family reunion. Each family will have the members get together to have a big dinner. The most popular food is moon cakes. They are round and look like the moon.
The moon is the brightest this night. People eat the delicious food while they are enjoying a beautiful full moon in their yard. At this time, some old people would like to tell many past events and tell the children a story about the rabbit on the moon . The children really believe that there is a rabbit on the moon. They hope to go to the moon and have a look one day.
As with many legends, there are differing and often contradictory accounts。和其余好些个风传同样，有关八月节的传说也是有广大例外的居然是互相冲突的本子。
The input contains no more than 10 test cases.
For each test case:
The first line includes two integers N and M. N is the total number of orders. M is the number of hours the shop opens.
The next N lines describe all the orders. Each line is in the following format:
One tells that Chang'e was a heavenly girl who worked among fairies and immortals in the palace of the Jade Emperor. One day, she broke a special porcelain jar and was banished to live among humans on earth, with the promise that she could return if she performed valuable deeds there。有一种版本中称，常娥原是玉皇上帝天宫中同别的仙女老天爷一同干活的半边天。有一天，她破裂了三个极度的瓷罐，因而被赶走到人世和人类生活在一道，独有当他做了好事她本领重复回到天上。
month date year H R
Joining a family of farmers, she met Houyi, a hunter and master archer, and eventually, they would marry。常娥在一户山民家里境遇了身为猎人和射手的司羿，后来他们成婚了。
It 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.
All the orders are sorted by the time in increasing order.
The 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.
Finally, M lines follow. Among those M lines, the ith line( i starts from 1) contains a integer indicating the cost to make a mooncake during the ith hour . The cost is no more than 10000. Jan 1st 2000 0 o'clock belongs to the 1st hour, Jan 1st 2000 1 o'clock belongs to the 2nd hour, …… and so on.
But the world of mortals soon found itself in peril. The Jade Emperor had 10 mischievous sons who transformed themselves into 10 suns, scorching the earth and its people. Houyi took it upon himself to save them. Using incredible strength and superior marksmanship, he shot down nine of the suns and left one in the sky so that humans could draw upon its warmth and light。不过俗世随后就应时而生了一触即发。玉皇大帝的10个爱搞怪的外甥化作13个太阳，炙烤着国内外和人类。后羿主动承责以挽回我们，他力大无比，射术超群，一口气射下了9个太阳，只留下一个给大伙儿带给温暖和光彩。
(0<N <= 2500; 0 < M,T <=100000; 0<=S <= 200; R<=10000 ; 0<=H<24)
It is here, again, that accounts diverge. One version has it that both Houyi and Chang'e were heavenly beings, and that a vengeful emperor condemned them to live on Earth as mortals thereafter. Houyi wished to avert death, so he acquired an elixir that would confer immortality. He was warned to drink only half the potion, and he reasoned that his wife could drink the rest。传说到此地又分为了分歧的本子。四个本子说后羿和常娥都以天上的菩萨，国王想要报复他们所以罚他们下尘寰成为人类。大羿为了能够长生不老得到了不死药。但他只被允许喝半瓶，剩下的半瓶他筹算留给内人。
The input ends with N = 0 and M = 0.
In one account of the legend, a greedy friend of Houyi's named Peng Meng tried to obtain the formula for himself, but Chang'e wouldn't let him, and drank it all. Another states that Chang'e could not resist immortality, and so consumed it herself。八个本子的传说中，后羿有多个称呼蓬蒙的朋友，他为人奸诈，一心想偷那瓶不死药。常娥为了不让他盗窃把整瓶都喝掉了。而另多少个版本中，常娥是因为受不了凡人的活着而喝掉了整瓶不死药。
You should output one line for each test case: the minimum cost.
However you interpret the legend, it eventually transpired that Chang'e's body became light, and she flew out a window up to the moon, leaving her husband all alone on the Earth。不过无论哪个版本，最终的结果都是常娥的肉身变得越发轻，接着她从窗子飞出飞向了明亮的月，把他的相爱的人独自壹个人留在了红尘。
Jan 1 2000 9 10
On a clear night, Houyi saw Chang'e in the moon, called out to her and even tried to shoot it down, but it was too late。在八个月明风清的晚间，大羿看见了光明的月上的月宫仙子，他大声喊她并计划把他射下来，可方方面面都太晚了。
Now a lunar goddess, Chang'e was doomed to be apart from her husband forever. Houyi honoured his wife by arranging a table with incense, meats and fruits that she loved. The tradition of making sacrifices to the moon carried through the ages, from the Western Zhou Dynasty (1045 to 770 B.C。卡塔尔国onward。近来看作光明的月靓妞，常娥注定与她的老公永恒抽离。大羿为了回顾爱妻会在桌子的上面摆上香炉以致他爱吃的肉片和瓜果。祭奠月球的观念意识就那样从东周时代(公元前1045年-前770年卡塔尔国承袭到现在。
And so it is today, that Chinese all over the world meet outside, eat together and gaze at a plentiful moon, like the legendary and historical ancestors who came before。因而后天世界各省的炎白人在这里个节日里都汇聚在联合签字，像传说里的上代们雷同，吃月饼、赏月球。