Affinity and Hostility in Divided Communities: A Mathematical Model