uint sum(uint a, uint b) { uint s = a + b; return (s < Nm) ? s : (s - Nm); }