Weakly commensurable S-arithmetic subgroups in almost simple algebraic groups of types B and C