spoj prob using strongly connected components