In the Cartesian plane, a point whose two coordinates are both integers is called a p-point. A p-segment is a closed line segment that is parallel to one of the coordinate axes and whose two endpoints are distinct p-points. A polyline made of k p-segments in which every two consecutive segments are perpendicular is called a p-broken-line of degree k.
You are given several p-segments together with two distinct p-points A and B. Find the smallest degree of a p-broken-line that joins A and B and shares no common point with any of the given p-segments, or determine that no such p-broken-line exists.
The vertices of the p-broken-line may be any p-points and are not restricted to the coordinates that appear in the input. Sharing a point is forbidden even at an endpoint of a p-segment, so the p-broken-line must stay completely off every given p-segment.
The first line contains two integers x and y (0≤x,y≤109), the coordinates of p-point A. The second line contains the coordinates of p-point B in the same format. The third line contains one integer n (1≤n≤50), the number of p-segments. Each of the next n lines contains four integers x1 y1 x2 y2, the coordinates of the two endpoints of one p-segment. Every p-segment is parallel to a coordinate axis and its two endpoints are distinct.
Print a single line with the minimum degree of a p-broken-line that connects A and B and shares no point with any given p-segment. If no such p-broken-line exists, print the word BRAK instead.