(OJ)two-gangs problem