Under construction

Still being built. Things may change

Neighbor

Time limit1sMemory limit1024 MB

Summary
Given two fractions, reduce their positive difference and output it if the numerator is 1, otherwise output NOT NEIGHBORS.
Level

Easy3 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Two fractions are called "neighbors" if the reduced positive difference between them has a numerator of 1. For example, 1/11 and 1/12 subtract to 1/132, so they are neighbors. However, 2/5 and 4/5 differ by 2/5, so they are not neighbors. Determine the "neighbor" difference between two fractions and output it, or output "NOT NEIGHBORS" if they are not neighbors.

Input

The first line contains a single positive integer n, the number of data sets. Each data set is one line with four positive integers separated by single spaces, in the order numerator, denominator, numerator, denominator.

Output

For each data set, output the positive difference between the two fractions if they are neighbors, or the phrase NOT NEIGHBORS otherwise.

Examples1

  1. Example 1

    Input
    3
    1 11 1 12
    20 19 19 19
    2 5 4 5
    
    Expected output
    1/132
    1/19
    NOT NEIGHBORS