Condition to check if the both the elements are in same diagonal of a matrix
if P - Q == I - J or P + Q == I + J : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT