4294: Berzerk

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:5 通过:5

题目描述

A. Berzerk
Rick和Morty正在玩他们自己版本的Berzerk(这与著名的Berzerk游戏没有任何共同之处)。这个游戏需要很大的空间,所以他们用电脑玩。
在这个游戏中,有n个编号从1到n的物体排列成一个圆圈(按顺时针顺序)。1号物体是一个黑洞,其他的是行星。这个星球上有一个怪物。里克和莫蒂还不知道是哪一个,只是他最初还没有进入黑洞,但Unity会在比赛开始前通知他们。但目前,他们希望为每一种可能的情况做好准备。
它们中的每一个都有一组介于1和n-1(含)之间的数字。Rick的集合是s1,有k1个元素,Morty的集合是s2,有k2个元素。其中一人先走,另一人换人。在每个玩家的回合中,他应该从他的集合中选择一个任意的数字,如x,怪物将从当前位置(顺时针)移动到他的第x个下一个对象。如果怪物在移动后到达黑洞,他就会获胜。
你的任务是,对于每个怪物的初始位置和谁先上场,决定先发者是赢还是输,或者游戏将陷入无限循环。如果玩家可以输掉或使游戏无限,选择无限游戏会更有利可图。

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 n objects numbered from 1 to n arranged in a circle (in clockwise order). object number 1 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 1 and n-1 (inclusive). Rick's set is s1 with k1 elements and Morty's is s2 with k2 elements. One of them goes first and the player changes alternatively. In each player's turn, he should choose an arbitrary number like x from his set and the monster will move to his x-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.
Input
The first line of input contains a single integer n (2≤n≤7000) − number of objects in game.
The second line contains integer k1 followed by k1 distinct integers s1,1,s1,2,...,s1,k1 − Rick's set.
The third line contains integer k2 followed by k2 distinct integers s2,1,s2,2,...,s2,k2 − Morty's set
1≤kin-1 and 1≤si,1,si,2,...,si,kin-1 for 1≤i≤2.
Output
In the first line print n-1 words separated by spaces where i-th word is "Win" (without quotations) if in the scenario that Rick plays first and monster is initially in object number i+1 he wins, "Lose" if he loses and "Loop" if the game will never end.
Similarly, in the second line print n-1 words separated by spaces where i-th word is "Win" (without quotations) if in the scenario that Morty plays first and monster is initially in object number i+1 he wins, "Lose" if he loses and "Loop" if the game will never end.
Examples
Input
5
2 3 2
3 1 2 3
Output
Lose Win Win Loop
Loop Win Win Win
Input
8
4 6 2 3 4
2 3 6
Output
Win Win Win Win Win Win Win
Lose Win Lose Lose Win Lose Lose

输入格式

输入
第一行输入包含单个整数n(2≤n≤7000)−游戏中的对象数。
第二行包含整数k1,后跟k1个不同的整数s1,1,s1,2,。。。,s1,k1–瑞克的集合。
第三行包含整数k2,后跟k2个不同的整数s2,1,s2,2,。。。,s2,k2−Morty集合
1≤ki≤n-1和1≤si,1,si,2,。。。,si,ki≤n-1表示1≤i≤2。

输出格式

输出
在第一行打印n-1个单词,用空格隔开,其中第i个单词是“赢”(没有引号),如果在Rick首先玩的场景中,怪物最初在对象编号i+1中,他赢了,如果他输了,则“输”,如果游戏永远不会结束,则“循环”。
类似地,在第二行打印n-1个单词,用空格隔开,其中第i个单词是“赢”(没有引号),如果在Morty首先玩的场景中,怪物最初在对象编号i+1中,他赢了,如果他输了,则“输”,如果游戏永远不会结束,则“循环”。

输入样例 复制

5
2 3 2
3 1 2 3

输出样例 复制

Lose Win Win Loop
Loop Win Win Win