If next i is odd ( next i is even ) then we need not to change firstr , we need to remove first character of second and append a character to it .
second = ( d * ( second + q - str [ ( i + 1 ) / 2 ] * h ) % q + str [ i + 1 ] ) % q ; } } } }