import Control.Applicative
import Data.List
count pos
= maybe 0 id $ findIndex
(elem pos
) positions
next x
= g
((map p
$ ((,)<$>[1,-1]<*>[2,-2]) ++ ((,)<$>[2,-2]<*>[1,-1])) <*> x
)p (a,b) (c,d) = (a+c, b+d)
g
= filter (\
(x
, y
) -> 0 <= x
&& 0 <= y
)
aW1wb3J0IENvbnRyb2wuQXBwbGljYXRpdmUKaW1wb3J0IERhdGEuTGlzdAoKbWFpbiA9IHB1dFN0ckxuICQgdW5saW5lcyBbY29uY2F0IFtzaG93ICQgY291bnQgKHgsIHkpfHg8LVswLi43XV18IHk8LVswLi43XV0KCmNvdW50IHBvcyA9IG1heWJlIDAgaWQgJCBmaW5kSW5kZXggKGVsZW0gcG9zKSBwb3NpdGlvbnMKCnBvc2l0aW9ucyA9IGl0ZXJhdGUgbmV4dCBbKDAsMCldCm5leHQgeCA9IGcgKChtYXAgcCAkICgoLCk8JD5bMSwtMV08Kj5bMiwtMl0pICsrICgoLCk8JD5bMiwtMl08Kj5bMSwtMV0pKSA8Kj4geCkKcCAoYSxiKSAoYyxkKSA9IChhK2MsIGIrZCkKZyA9IGZpbHRlciAoXCh4LCB5KSAtPiAwIDw9IHggJiYgMCA8PSB5KQo=