SPOJ problem WORDS using eulerian path concept