added spoj ppath solution