isValid :: Edge -> Bool
isValid ((p1,p2),(q1,q2)) = x || y
  where x = abs (p1-q1) == 1 && p2 == q2
        y = abs (p2-q2) == 1 && p1 == q1
isValid :: Edge -> Bool
isValid ((p1,p2),(q1,q2)) = x || y
  where x = abs (p1-q1) == 1 && p2 == q2
        y = abs (p2-q2) == 1 && p1 == q1
isValid ((p1,p2),(q1,q2)) = x || y
  where x = abs (p1-q1) == 1 && p2 == q2
        y = abs (p2-q2) == 1 && p1 == q1