We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- Practice
- Mathematics
- Geometry
- Points On a Line

# Points On a Line

# Points On a Line

Given two-dimensional points in space, determine whether they lie on some vertical or horizontal line. If yes, print *YES*; otherwise, print *NO*.

**Input Format**

The first line contains a single positive integer, , denoting the number of points.

Each line of subsequent lines contain two space-separated integers detailing the respective values of and (i.e., the coordinates of the point).

**Constraints**

**Output Format**

Print *YES* if all points lie on some horizontal or vertical line; otherwise, print *NO*.

**Sample Input 0**

```
5
0 1
0 2
0 3
0 4
0 5
```

**Sample Output 0**

```
YES
```

**Explanation 0**

All points lie on a vertical line.

**Sample Input 1**

```
5
0 1
0 2
1 3
0 4
0 5
```

**Sample Output 1**

```
NO
```

**Explanation 1**

The points do not all form a horizontal or vertical line.