Spoj VPARTY .. hint

I have been trying to solve this question for quite some time now. I have realised we cannot use maximum flow here (I could be wrong). Can some please point to me towards an approach for this question…??
PS: http://www.spoj.pl/problems/VPARTY/
Thank you

//