Use unsigned longs to avoid overflow.