#34. The Mysteries of Hyrule’s Runes

The Mysteries of Hyrule’s Runes

Background

In the land of Hyrule, a realm guarded by mysterious powers, the valiant Link emerged victorious from an epic battle, safeguarding the peace of the continent. Yet, this tranquility was short-lived as a mysterious celestial body, known as the "Tears of the Kingdom," descended from the heavens, crashing into the heart of the land and unleashing strange and powerful forces!

This energy awoke ancient magic, causing bizarre transformations among the creatures and abilities across the continent. Determined to uncover the secrets of the "Tears of the Kingdom" and to rescue Princess Zelda, Link embarked on a journey fraught with the unknown and danger. Along the way, he discovered ancient magical runes that held the power of the "Tears" and could aid him in overcoming the resurgent evil forces. 随便找的图

Description

In Hyrule, There are n*m magical elements such as Fire, Lightning, Ice, and Forest......this means that every element is unique. Link found that a newly generated element from a unique runes(符文)(represented by the integer n, ranging from 0 to n-1)and a unique incantation(咒语) (represented by the integer m, ranging from 0 to m-1),which we can define a newly element as (n1, m1). Link has collected some of these elements during his travels and found that when 5 elements are combined, they unleash incredible power!
According to an ancient Hylian legend, Link has uncovered the following nine mystical amazing combinations of elements, each with its unique rules:
1.Quantum Elemental Chain Alliance(量子元素链盟):
Elements satisfies both Continuous Energy Pulse Chain and Elemental Unity Wave.
2. Continuous Energy Pulse Chain(连续能量脉冲链):
For five elements ai, the runes satisfy a,a+1,a+2,a+3,a+4.
3. Elemental Unity Wave(元素统一波动):
Five runes of the same incantation.
4. Energy Burst Incantation(四重能量爆炸):
Five elements with four having the same rune.
5. Triple Energy Conduction Incantation(三重能量引导):
Five elements with three having the same rune, and the other two also sharing the same rune.
6. Dual Energy Frequency Resonance(双能频率共鸣):
Five elements with two having the same rune, and two more out of the remaining three also sharing the same rune.
7. Triple Energy Field Shield(三能场域护盾):
Five elements with three having the same rune.
8. Energy Resonance Incantation(能量谐波共振):
Five elements with two having the same rune.
9. Rune Shatter Spell(符文结构崩溃咒):
The elements in hand do not satisfy any of the aforementioned combinations.
Link's goal is to match the elements he holds to the corresponding combination number (an integer between 1 and 9), with a lower number indicating a more powerful combination.This is to say:the rules from 1 to 9, in order of first fulfilment, are the marvellous combinations that the elements can produce. During one of his adventures, Link has already selected two elements, which are (n1, m1) and (n2, m2). Now, he will randomly choose three more from the remaining elements to form a set. Aware that mastering the secrets of these rune combinations will aid him in revealing the mysteries of the "Tears of the Kingdom" and overcoming the dark forces to save the princess, Link seeks assistance. Having lost his precious Sword of Wisdom, he can no longer foresee his future. Therefore, he needs your help to calculate the number of possible combinations for each of the nine sets. This will prepare him for the challenges ahead and uncover the enigmas of the "Tears of the Kingdom"!
In simple terms, we have already chosen 2 elements, and now we need to pick 3 from them. Finally, we need to tally the number of amazing combinations that arise from all possible selection methods.

Format

Input

-The first line contains integers n and m.
Respectively, means that there are now n runes, m incantations. (5 ≤ n ≤ 25, 1 ≤ m ≤ 4).
-The second line contains integers: n1, m1, n2, m2,which represents the two elements that Link already possesses in his hands.(0 ≤ n1, n2 ≤ n - 1, 0 ≤ m1, m2 ≤ m - 1, (n1, m1) ≠ (n2, m2)).

Output

Output one line containing 9 integers, where each integer represents the number of ways each of the 9 possible combinations can occur,in order from the smallest to the largest according to the rules numbering.

Sample 1

5 2
0 0 1 1
0 8 0 0 0 12 0 36 0

Explaination 1

There are 5 runes 2 incantations,a total o f 10 unique elements, and what Link has in his hands right now are the two elements (0,0), (1,1) respectively. There are 0,8,0,0,0,12,0,36,0 and 0 amazing combinations that satisfy the rules 1 to 9 respectively.

Sample 2

25 4
1 1 0 0
0 64 0 2 18 1656 644 36432 113280

Limitation

Time limit: 2000 ms
Mem limit: 262144 kb