CF786A.Berzerk

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Rick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.

In this game there are nn objects numbered from 11 to nn arranged in a circle (in clockwise order). Object number 11 is a black hole and the others are planets. There's a monster in one of the planet. Rick and Morty don't know on which one yet, only that he's not initially in the black hole, but Unity will inform them before the game starts. But for now, they want to be prepared for every possible scenario.

Each one of them has a set of numbers between 11 and n1n-1 (inclusive). Rick's set is s1s_{1} with k1k_{1} elements and Morty's is s2s_{2} with k2k_{2} elements. One of them goes first and the player changes alternatively. In each player's turn, he should choose an arbitrary number like xx from his set and the monster will move to his xx -th next object from its current position (clockwise). If after his move the monster gets to the black hole he wins.

Your task is that for each of monster's initial positions and who plays first determine if the starter wins, loses, or the game will stuck in an infinite loop. In case when player can lose or make game infinity, it more profitable to choose infinity game.

输入格式

The first line of input contains a single integer nn ( 2<=n<=70002<=n<=7000 ) — number of objects in game.

The second line contains integer k1k_{1} followed by k1k_{1} distinct integers s1,1,s1,2,...,s1,k1s_{1,1},s_{1,2},...,s_{1,k1} — Rick's set.

The third line contains integer k2k_{2} followed by k2k_{2} distinct integers s2,1,s2,2,...,s2,k2s_{2,1},s_{2,2},...,s_{2,k2} — Morty's set

1<=ki<=n11<=k_{i}<=n-1 and 1<=si,1,si,2,...,si,ki<=n11<=s_{i,1},s_{i,2},...,s_{i,ki}<=n-1 for 1<=i<=21<=i<=2 .

输出格式

In the first line print n1n-1 words separated by spaces where ii -th word is "Win" (without quotations) if in the scenario that Rick plays first and monster is initially in object number i+1i+1 he wins, "Lose" if he loses and "Loop" if the game will never end.

Similarly, in the second line print n1n-1 words separated by spaces where ii -th word is "Win" (without quotations) if in the scenario that Morty plays first and monster is initially in object number i+1i+1 he wins, "Lose" if he loses and "Loop" if the game will never end.

输入输出样例

  • 输入#1

    5
    2 3 2
    3 1 2 3
    

    输出#1

    Lose Win Win Loop
    Loop Win Win Win
    
  • 输入#2

    8
    4 6 2 3 4
    2 3 6
    

    输出#2

    Win Win Win Win Win Win Win
    Lose Win Lose Lose Win Lose Lose
    
首页