Can someone please explain the solution of this Problem

Problem Statement: SPOJ.com - Problem GHOSTS

no question clarity, what is a and b not mentioned in the question

‘a’ and ‘b’ are connected edges.