Geeksforgeeks

Timer is Running

Given two coordinates (x, y) and (a, b). Find if it is possible to reach (x,y) from (a,b).

Only possible moves from any coordinate (i, j) are

- (i-j, j)
- (i, i-j)
- (i+j, j)
- (i, i+j)

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the integers x, y, a and b in that sequence.

**Output:**

Print 1 if it is possible to reach (a, b) from (x, y) under the above-mentioned constraints else print 0.

**Constraints:**

1 <= T <= 100

-1000 <= x, y, a, b <= 1000

**Example:**

**Input:**

2

1 1 2 3

35 15 20 25

**Output:**

1

1

**Explanation:
Input: **(x, y) = (35, 15) and (a, b) = (20, 25).

**Output: **Yes.

(35, 15) -> (20, 15) -> (5, 15) -> (5, 10) -> (5, 5) ->(10, 5) -> (15, 5) -> (20, 5) -> (20, 25)

Author: Dharmesh

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Pathak1899 | 436 |

yashdip123 | 380 |

kirtidee18 | 377 |

ykaushik | 261 |

_saswata | 232 |

kirtidee18 | 1057 |

ykaushik | 733 |

aggarwalvatsal5 | 709 |

pmr_3689 | 570 |

harbilassingh | 530 |

blackshadows | 5456 |

Ibrahim Nash | 5450 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4823 |

Login to report an issue on this page.