Modified Q algorithm to GM(4)