Outfits

No attempts yetTime limit1sMemory limit128 MB

Problem

Becs and Cas are best friends who buy their clothes from the same store, so they always end up owning exactly the same outfits. They would be mortified to wear the same outfit on the same day.

Because they copy each other so closely, their two wardrobes contain exactly the same outfits hanging in exactly the same order. Occasionally, though, one of them decides she hates a particular outfit and throws it away, without telling the other.

The two friends number their outfits differently:

  • Becs numbers her outfits from left to right, so her outfit 1 is the leftmost one.
  • Cas numbers her outfits from right to left, so her outfit 1 is the rightmost one.

Physically the two wardrobes still look the same; for instance, the leftmost outfit in each wardrobe is the same outfit. When a girl throws an outfit away, the remaining outfits keep their order, and she renumbers the ones that are left according to her own direction.

Write a program that, for each day, warns the girls whenever they have picked the very same outfit.

Input

The input contains several scenarios.

Each scenario begins with a line containing two integers nn and dd, where 5<n505 < n \le 50 is the number of outfits in each girl's wardrobe before anything is thrown away, and dd is the number of days to consider. A scenario line of 0 0 marks the end of the input and must not be processed.

The next two lines describe the outfits that have been thrown away, one line per girl (Becs first, then Cas). Each line contains a single integer rr with 0rn0 \le r \le n. A value of 00 means the girl has thrown nothing away; any other value means she has removed the outfit with that number in her own numbering system (Becs counting from the left, Cas from the right). At most one outfit is removed from each wardrobe.

After the removal lines come dd lines, one per day. Each of these lines contains two integers separated by a space: Becs' choice first, then Cas'. Becs' number counts from the left of her current wardrobe and Cas' number counts from the right of hers, always among the outfits each girl still owns. For example, a day line 3 12 means Becs chose the 3rd outfit from the left of her wardrobe while Cas chose the 12th outfit from the right of hers.

Output

For each scenario, print a line Scenario s, where ss is the scenario number starting from 11. Then, for each of that scenario's days, print a line Day k R, where kk is the day number (starting from 11) and RR is OK if the two girls picked different outfits or ALERT if they picked the same outfit.