<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

120. Archipelago

time limit per test: 0.25 sec.
memory limit per test: 4096 KB


Archipelago Ber-Islands consists of N islands that are vertices of equiangular and equilateral N-gon. Islands are clockwise numerated. Coordinates of island N1 are (x1, y1), and island N2 – (x2, y2). Your task is to find coordinates of all N islands.


Input

In the first line of input there are N, N1 and N2 (3£ N£ 150, 1£ N1,N2£N, N1¹N2) separated by spaces. On the next two lines of input there are coordinates of island N1 and N2 (one pair per line) with accuracy 4 digits after decimal point. Each coordinate is more than -2000000 and less than 2000000.


Output

Write N lines with coordinates for every island. Write coordinates in order of island numeration. Write answer with 6 digits after decimal point.


Sample Input

4 1 3
1.0000 0.0000
1.0000 2.0000
Sample Output

1.000000 0.000000
0.000000 1.000000
1.000000 2.000000
2.000000 1.000000
Author	: Michael R. Mirzayanov
Resource	: PhTL #1 Training Contests
Date	: Fall 2001

<|response|>
1. Abridged Problem Statement  
You have a regular N-gon (vertices numbered 1…N in clockwise order). You know the 2D coordinates of two distinct vertices, say index a and index b. Recover the coordinates of all N vertices in index order, printing each with six decimal places.

2. Key Observations  
- A regular N-gon is inscribed in a circle (circumcircle) of some center C and radius R.  
- The central angle between vertices a and b is Δ = 2π·|b−a|/N.  
- The straight-line distance d = |A−B| is the chord length spanning that angle.  
- From the chord–radius relation: d = 2R·sin(Δ/2), so R = d/(2·sin(Δ/2)).  
- The center C lies on the perpendicular bisector of segment AB, at distance h = (d/2)/tan(Δ/2) from the midpoint M of AB.  
- Once C and R are known, if φ is the polar angle of A relative to C (φ = atan2(A.y−C.y, A.x−C.x)), then the i-th vertex (counting clockwise) has angle φ_i = φ + 2π·(a−i)/N, and its coordinates are C + R·(cosφ_i, sinφ_i).

3. Full Solution Approach  
1. Read N, a, b and the given points A=(x_a,y_a), B=(x_b,y_b).  
2. If a>b, swap a↔b and A↔B, so that a<b.  
3. Compute d = distance(A,B).  
4. Compute half-angle α = π·(b−a)/N (so that Δ=2α).  
5. Compute radius R = d / (2·sin α).  
6. Compute midpoint M = (A+B)/2.  
7. Compute h = (d/2) / tan α.  
8. The vector from A to B is v=(dx,dy)=(B.x−A.x, B.y−A.y).  
   A perpendicular direction is p = (dy, −dx) (rotating v by +90°).  
   Normalize p to length h: p_scaled = p * (h / d).  
9. Choose center C = M + p_scaled.  (This orientation matches the clockwise numbering.)  
10. Compute φ = atan2(A.y−C.y, A.x−C.x).  
11. For i from 1 to N:  
    - If i==a, output A; if i==b, output B.  
    - Otherwise, compute φ_i = φ + 2π·(a−i)/N, and P_i = C + R·(cosφ_i, sinφ_i). Output P_i.  

All steps take O(N) time and O(1) extra memory beyond storing N points.

4. C++ Implementation with Detailed Comments  
```cpp
#include <bits/stdc++.h>
using namespace std;
// We use complex<long double> to handle 2D points/vectors cleanly.
using Point = complex<long double>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, a, b;
    cin >> N >> a >> b;

    // Read the two known vertices
    long double xa, ya, xb, yb;
    cin >> xa >> ya;
    cin >> xb >> yb;
    Point A(xa, ya), B(xb, yb);

    // Ensure a < b by swapping if necessary
    if(a > b){
        swap(a, b);
        swap(A, B);
    }

    const long double PI = acosl(-1.0L);

    // 1) Chord length between A and B
    long double d = abs(B - A);

    // 2) Half the central angle: α = π*(b-a)/N
    long double alpha = PI * (b - a) / N;

    // 3) Circumradius: d = 2·R·sin(α)  ⇒  R = d / (2·sin α)
    long double R = d / (2.0L * sinl(alpha));

    // 4) Midpoint of AB
    Point M = (A + B) / 2.0L;

    // 5) Distance from M to center along perpendicular bisector: h = (d/2)/tan α
    long double h = (d / 2.0L) / tanl(alpha);

    // 6) Perpendicular direction to AB: (dx, dy) → (dy, -dx)
    long double dx = B.real() - A.real();
    long double dy = B.imag() - A.imag();
    Point perp(dy, -dx); 

    // Normalize to length h
    perp *= (h / d);

    // 7) Choose the correct center so that numbering is clockwise
    Point C = M + perp;

    // 8) Base angle φ of point A around center C
    long double phi = atan2l(A.imag() - C.imag(), A.real() - C.real());

    // 9) Generate and print all N vertices
    cout << fixed << setprecision(6);
    for(int i = 1; i <= N; i++){
        Point P;
        if(i == a){
            P = A;
        } else if(i == b){
            P = B;
        } else {
            // Clockwise step: Δθ = 2π*(a - i)/N
            long double theta = phi + 2.0L * PI * (a - i) / N;
            P = C + Point(R * cosl(theta), R * sinl(theta));
        }
        cout << P.real() << " " << P.imag() << "\n";
    }

    return 0;
}
```

5. Python Implementation with Detailed Comments  
```python
import math
import sys

def main():
    data = sys.stdin.read().split()
    N, a, b = map(int, data[:3])
    xa, ya = map(float, data[3:5])
    xb, yb = map(float, data[5:7])
    A = complex(xa, ya)
    B = complex(xb, yb)

    # Ensure a < b by swapping if needed
    if a > b:
        a, b = b, a
        A, B = B, A

    # 1) Chord length
    d = abs(B - A)

    # 2) Half central angle α = π*(b-a)/N
    PI = math.pi
    alpha = PI * (b - a) / N

    # 3) Circumradius R = d / (2 sin α)
    R = d / (2 * math.sin(alpha))

    # 4) Midpoint M of AB
    M = (A + B) / 2

    # 5) Distance from M to center: h = (d/2)/tan α
    h = (d / 2) / math.tan(alpha)

    # 6) Perpendicular direction: rotate (dx,dy)->(dy,-dx), normalize to h
    dx = B.real - A.real
    dy = B.imag - A.imag
    perp = complex(dy, -dx) * (h / d)

    # 7) Choose center C = M + perp
    C = M + perp

    # 8) Base angle φ of A around C
    phi = math.atan2(A.imag - C.imag, A.real - C.real)

    # 9) Generate all N vertices
    step = 2 * PI / N
    out = []
    for i in range(1, N+1):
        if i == a:
            P = A
        elif i == b:
            P = B
        else:
            theta = phi + step * (a - i)  # clockwise numbering
            P = C + R * complex(math.cos(theta), math.sin(theta))
        out.append(f"{P.real:.6f} {P.imag:.6f}")

    sys.stdout.write("\n".join(out))

if __name__ == "__main__":
    main()
```