You are given a set of N line segments that are either horizontal or vertical. Write a program to determine the points of intersection of all the horizontal line segments with the vertical line segments.
Note: Do not consider the coincident endpoints as intersections.
Input format
Output format
Sort and print all the intersection points of the horizontal and the vertical line segments. The intersection point is represented as (x, y) with space between them.
Constraints
1≤N≤103
For horizontal line:
1≤x1<x2≤106
1≤y1=y2≤106
For vertical line:
1≤x1=x2≤106
1≤y1<y2≤106
The intersections are (2,2) and (3,2)