403201: GYM101064 H Pop Divas

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Pop Divastime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Glauber "the drinker" Sokolov, after participating in two ICPC World Finals, decided to abandon competitive programming and pursue his dream of working with the pop divas. His first job was as a dancer in one of Britney Spears' concerts, then composing songs for Lana del Rey, and he worked with Rihanna, Shakira, and many others. As time passed he used his unmatched intelligence to rise to the top, and became a producer.

Each song has an attribute named quality, that depends on how catchy it is, how touching the lyrics are and how danceable is the beat. This value can be represented as a number in the range [0,  + ∞]. When choosing the tracks for an album, the quality of an album is equal to the glauber mean of the qualities all the songs in that album, that is, if a1, ..., aB are the qualities of the songs chosen for an album, then the quality of the album is .

The quality of an album is closely related to how much it will sell and how it will be portrayed on the media. Producers don't usually know the quality of their singers' songs, but Glauber is no simple producer.

Glauber manages both Katy Perry and Taylor Swift music, and both divas are about to release an album. Each singer has a collection of songs, and Glauber will choose one or more songs from that collection to create an album. As both singers are very good, Glauber knows the quality of all of their songs are integers not smaller than one.

To avoid creating any more bad blood between them, Glauber wants to choose albums with the same quality, so that the media won't compare them and rate one as better than the other. He forgot how to do that since he stopped programming, can you help him?

Input

The first line has two integers N and M, the size of the collection of songs from Taylor Swift and Katy Perry, respectively.

The second line has N integers a1, ..., aN, the qualities of the songs from Taylor.

The third line has M integers b1, ..., bM, the qualities of the songs from Katy.

Limits

  • 1 ≤ N, M ≤ 16
  • 1 ≤ ai, bj ≤ 109
Output

In the first line print "Y" if it is possible to choose such albums, and "N" otherwise.

If it is possible, print the sizes of the albums from Taylor and Katy in one line, and the quality of their songs in the next two lines, in the same format as in the input. The values for each album can be printed in any order. If there are multiple answers, you can print any of them.

ExamplesInput
2 3
2 15
6 5 7
Output
Y
2 2
2 15
6 5
Input
3 5
2 3 5
7 11 13 17 19
Output
N

Source/Category

加入题单

上一题 下一题 算法标签: