<|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.

151. Construct a triangle
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard input
output: standard output



Find coordinates of any triangle ABC if it is know that |AB|=c, |AC|=b, |AM|=m, AM is a median of triangle.

Input
There are three real numbers in input: c, b, m (0<c,b,m<=10^3) separated by a space. Length of the fractional part of each number is not greater than 2 digits.

Output
If solution exists, write three lines. Write coordinates of point A to first line, coordinates of B to second line and coordinates of C to third line. Separate numbers by a space; absolute value of each coordinate must not exceed 10^4. Write numbers with 5 digits after decimal point. If there is no solution, write "Mission impossible"

Sample test(s)

Input
5 5 3

Output
0.00000 3.00000
-4.00000 0.00000
4.00000 0.00000
Author:	Michael R. Mirzayanov
Resource:	Saratov Subregional School Team Contest, 2002
Date:	Spring, 2002

<|response|>
1. Abridged problem statement  
Given three real numbers c, b, m (all > 0), construct any triangle ABC such that  
  • |AB| = c  
  • |AC| = b  
  • AM is the median from A to side BC, of length m.  
If no such triangle exists, print “Mission impossible”. Otherwise, print coordinates of A, B, C (one point per line) with five decimal places.  

2. Key observations needed to solve the problem  
- In any triangle, the median from A onto BC has length m satisfying  
   m² = (2b² + 2c² − a²) / 4,  
  where a = |BC|.  
- Rearranging gives  
   a² = 2(b² + c²) − 4m².  
- For a real triangle we need  
   a² ≥ 0  and  triangle inequalities:  
   a + b > c,  a + c > b,  b + c > a.  
- Once a is known, place A and B in a simple coordinate system:  
   A = (0,0),  B = (c,0).  
- Use the law of cosines at A to find the angle ∠BAC:  
   cos A = (AB² + AC² − BC²) / (2·AB·AC)  
         = (c² + b² − a²) / (2bc).  
- Then compute sin A = √(1 − cos² A), and set  
   C = (b·cos A, b·sin A).  

3. Full solution approach based on the observations  
1. Read inputs c, b, m.  
2. Compute inner = 2·(b² + c²) − 4·m².  
3. If inner < 0, no real a exists ⇒ print “Mission impossible” and exit.  
4. Let a = √inner.  
5. Check triangle inequalities (a + b > c, a + c > b, b + c > a). If any fail, print “Mission impossible” and exit.  
6. Compute cosA = (c² + b² − a²) / (2bc). Clamp cosA into [−1,1] to avoid tiny numerical errors.  
7. Compute sinA = √(1 − cosA²).  
8. Set coordinates:  
   A = (0.00000, 0.00000)  
   B = (c, 0.00000)  
   C = (b·cosA, b·sinA)  
9. Print A, B, C with five digits after the decimal point.  

4. C++ implementation with detailed comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

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

    double c, b, m;
    // Read side lengths c = |AB|, b = |AC| and median length m = |AM|
    if (!(cin >> c >> b >> m)) return 0;

    // 1) Compute a^2 using median formula: a^2 = 2(b^2 + c^2) - 4m^2
    double inner = 2.0*(b*b + c*c) - 4.0*m*m;
    if (inner < 0.0) {
        // No real solution for side BC
        cout << "Mission impossible\n";
        return 0;
    }

    // 2) Compute a = |BC|
    double a = sqrt(inner);

    // 3) Check triangle inequalities
    if (a + b <= c || a + c <= b || b + c <= a) {
        cout << "Mission impossible\n";
        return 0;
    }

    // 4) Compute cosine of angle A by the law of cosines:
    //    cosA = (AB^2 + AC^2 - BC^2) / (2 * AB * AC)
    double cosA = (c*c + b*b - a*a) / (2.0 * b * c);
    // Clamp to [-1,1]
    cosA = max(-1.0, min(1.0, cosA));
    // 5) Compute sinA
    double sinA = sqrt(max(0.0, 1.0 - cosA*cosA));

    // 6) Assign coordinates
    double Ax = 0.0, Ay = 0.0;
    double Bx = c,    By = 0.0;
    double Cx = b * cosA;
    double Cy = b * sinA;

    // 7) Output with five decimal places
    cout << fixed << setprecision(5);
    cout << Ax << " " << Ay << "\n";
    cout << Bx << " " << By << "\n";
    cout << Cx << " " << Cy << "\n";
    return 0;
}
```

5. Python implementation with detailed comments  
```python
import math
import sys

def main():
    data = sys.stdin.read().strip().split()
    if len(data) != 3:
        # Invalid input format
        return
    c, b, m = map(float, data)

    # 1) Compute squared length of BC using the median formula
    #    a^2 = 2(b^2 + c^2) - 4*m^2
    inner = 2*(b*b + c*c) - 4*(m*m)
    if inner < 0:
        print("Mission impossible")
        return

    # 2) Compute a = |BC|
    a = math.sqrt(inner)

    # 3) Check triangle inequalities
    if a + b <= c or a + c <= b or b + c <= a:
        print("Mission impossible")
        return

    # 4) Compute cos(A) using the law of cosines
    cosA = (c*c + b*b - a*a) / (2 * b * c)
    # Clamp to [-1,1] for numerical stability
    cosA = max(-1.0, min(1.0, cosA))
    # 5) Compute sin(A)
    sinA = math.sqrt(1.0 - cosA*cosA)

    # 6) Place A at (0,0), B at (c,0), C at (b·cosA, b·sinA)
    A = (0.0, 0.0)
    B = (c,   0.0)
    C = (b * cosA, b * sinA)

    # 7) Print results with 5 decimal places
    for x, y in (A, B, C):
        print(f"{x:.5f} {y:.5f}")

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

Explanation of the main steps:  
- We derive the third side BC from the given median by the well‐known formula.  
- We verify that a valid triangle can be formed (non‐negative side, triangle inequalities).  
- We fix A and B on the x‐axis, then place C using the law of cosines.  
- Any triangle satisfying the conditions is acceptable within the required precision.