The learning of balanced and unbalanced social structures