If both A and B doesn 't change in  this recusrive call, then return INT_MAX  to save the code from going into  infinite loop
INDENT if ( A == prevA and B == prevB ) : NEW_LINE INDENT return 10 ** 9 ; NEW_LINE DEDENT DEDENT