## 1. Abridged Problem Statement

Given an undirected simple graph with 1 ≤ n ≤ 7, decide whether it is a unit-distance graph: can we place its vertices as points in the plane so that:

- If (u,v) is an edge, then the Euclidean distance between their points is exactly 1 (tolerance 10^-7).
- If (u,v) is not an edge, then their distance is not 1 (must differ from 1 by at least 10^-2).
- No two points are closer than 10^-2.
- Coordinates must have absolute value ≤ 100.

Output "Yes" and coordinates if possible, otherwise output "No".

---

## 2. Detailed Editorial

### Key idea: turn geometry constraints into optimization ("energy minimization")

We must assign 2D coordinates (x_i, y_i) for each vertex i. Define the distance between vertices i, j:

    d_ij = sqrt((x_i - x_j)^2 + (y_i - y_j)^2)

We need:
- For edges: d_ij = 1
- For non-edges: |d_ij - 1| ≥ 10^-2
- Distinctness: d_ij ≥ 10^-2

Instead of solving these constraints combinatorially, the solution uses continuous optimization with gradient descent and random restarts.

---

### Energy (loss) function

We minimize a sum of penalties over all unordered pairs (i, j):

**(A) Edge penalty** — for edges, enforce distance 1 via squared error:

    E_edge = sum_{(i,j) in E} (d_ij - 1)^2

**(B) Non-edge "forbidden band" around 1** — for non-edges, distance must not be near 1. The checker requires |d_ij - 1| ≥ ε where ε = 10^-2. The optimization only penalizes when a non-edge falls inside this band. If |d_ij - 1| < ε, push it to the nearest boundary:
- target = 1 - ε if d_ij < 1
- target = 1 + ε if d_ij > 1

Then add (d_ij - target)^2. If |d_ij - 1| ≥ ε, add nothing.

**(C) Distinctness penalty** — if points get too close (< 10^-2), push them apart:

If d_ij < δ where δ = 10^-2:

    E_distinct += (d_ij - δ)^2

---

### Gradient computation

For a term (d_ij - T)^2, where T is the desired target distance, the gradient w.r.t. coordinates is:

Let p_i = (x_i, y_i). Then:
- d_ij = ||p_i - p_j||
- ∇_{p_i} d_ij = (p_i - p_j) / d_ij

So:
    ∇_{p_i} (d_ij - T)^2 = 2(d_ij - T) * (p_i - p_j) / d_ij

The gradient on j is the negative. The code computes:
- dx = x_i - x_j, dy = y_i - y_j
- d = sqrt(dx^2 + dy^2) + 10^-12 (tiny additive to avoid divide-by-zero)
- scalar g = 2(d - T) / d
- then add g*dx and g*dy to i, subtract from j

---

### Optimization loop and random restarts

The loss is non-convex (many local minima), especially because:
- non-edge penalty is conditional (piecewise)
- multiple constraints may conflict

So the code repeatedly:
1. Randomly initializes all points uniformly in a square [-7, 7]^2.
2. Runs gradient descent for up to 10,000 iterations with:
   - initial learning rate 0.05
   - exponential decay by 0.999 each iteration
3. Verifies with the exact judge tolerances.
4. Stops when time limit (~0.6s inside a 0.75s limit) is reached.

Because n ≤ 7, the pairwise loop is tiny: C(7,2) = 21 pairs, so many iterations and restarts are feasible.

---

### Verification

After optimization, the program checks:
- distinctness: d ≥ 10^-2
- edges: |d - 1| ≤ 10^-7
- non-edges: |d - 1| ≥ 10^-2

If satisfied, it prints "Yes" and the coordinates.

---

### Complexity

For each gradient step, it considers all pairs: O(n^2) with n ≤ 7 — effectively constant time. Total work is iterations × restarts, bounded by the time limit.

---

## 3. C++ Solution

```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

const long double EPS_EDGE = 1e-7;
const long double EPS_NON_EDGE = 1e-2;
const long double EPS_DISTINCT = 1e-2;
const long double MAX_COORD = 7.0;
const long double TIME_LIMIT = 0.6;
const long double LR_START = 0.05;
const long double LR_DECAY = 0.999;
const int MAX_ITERS = 10000;

int n, m;
vector<pair<int, int>> edges;
vector<vector<bool>> adj;
vector<long double> x, y;

void read() {
    cin >> n >> m;
    adj.assign(n, vector<bool>(n, false));
    x.resize(n);
    y.resize(n);
    edges.clear();
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        edges.emplace_back(u, v);
        adj[u][v] = adj[v][u] = true;
    }
}

bool verify_solution() {
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            long double dx = x[i] - x[j];
            long double dy = y[i] - y[j];
            long double d = sqrt(dx * dx + dy * dy);

            if(d < EPS_DISTINCT) {
                return false;
            }
            if(adj[i][j]) {
                if(fabsl(d - 1.0) > EPS_EDGE) {
                    return false;
                }
            } else {
                if(fabsl(d - 1.0) < EPS_NON_EDGE) {
                    return false;
                }
            }
        }
    }
    return true;
}

void solve() {
    // We can solve the unit-distance graph problem by formulating it as a
    // continuous optimization problem and applying gradient descent with random
    // restarts. For each vertex i (0 ≤ i < n), we assign two variables for the
    // coordinates (x_i, y_i). Let d_ij = sqrt((x_i - x_j)^2 + (y_i - y_j)^2)
    // be the Euclidean distance between vertices i and j. The we can minimize a
    // total energy E consisting of three parts:
    //
    //     1) Edge length constraints. For every edge (i, j), the distance must
    //        be exactly 1. We penalize squared deviation from 1:
    //            E_edge = sum_{(i,j) in edges} (d_ij - 1)^2
    //
    //     2) Non-edge forbidden band. For non-edges, the distance must NOT be
    //        close to 1. We introduce a forbidden band of width 1e-2 around 1.
    //        Only when a non-edge distance enters this band do we penalize it:
    //            For (i, j) not an edge:
    //                if |d_ij - 1| < 1e-2:
    //                    target = 1 - 1e-2           if d_ij < 1
    //                             1 + 1e-2           if d_ij > 1
    //                    E_nonedge += (d_ij - target)^2
    //
    //     3) All points must remain distinct. If two points get closer than
    //        1e-2, we push them apart:
    //
    //            E_distinct += max(0, 1e-2 - d_ij)^2
    //
    // The total energy is then:
    //     E = E_edge + E_nonedge + E_distinct
    //
    // Let's optimize this with gradient descent.
    // For the (d_ij - T)^2 terms, the gradient for point i is the below:
    //
    //     d/d(x_i, y_i) = 2 (d_ij - T) * ((x_i - x_j), (y_i - y_j)) / d_ij
    //
    // While for point j, we directly have the negative. This can be shown from:
    //
    //     d_ij = |p_i - p_j|
    //         and
    //     grad{p_i} d_ij = (p_i - p_j) / d_ij
    //
    // To optimize this, we might have to tune the learning rate a bit, and make
    // some restarts, but it's doable for the given constraints. We should note
    // that we have branching in this solution, so the initialization does
    // matter and the function isn't convex and we might end up in a state where
    // it's impossible to satisfy the (2) constraints. This lack of convexity is
    // why we end up making multiple restarts. Alternatively, we could have went
    // for a SGD-like approach of considering smaller batches instead of the
    // full loss.

    auto start = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_real_distribution<long double> init(-MAX_COORD, MAX_COORD);

    while((long double)(clock() - start) / CLOCKS_PER_SEC < TIME_LIMIT) {
        for(int i = 0; i < n; i++) {
            x[i] = init(rng);
            y[i] = init(rng);
        }

        long double lr = LR_START;
        for(int iter = 0; iter < MAX_ITERS; iter++) {
            vector<long double> gx(n, 0), gy(n, 0);

            for(int i = 0; i < n; i++) {
                for(int j = i + 1; j < n; j++) {
                    long double dx = x[i] - x[j];
                    long double dy = y[i] - y[j];
                    long double d = sqrt(dx * dx + dy * dy) + 1e-12;

                    if(adj[i][j]) {
                        long double diff = d - 1.0;
                        long double g = 2 * diff / d;
                        gx[i] += g * dx;
                        gy[i] += g * dy;
                        gx[j] -= g * dx;
                        gy[j] -= g * dy;
                    } else {
                        if(abs(d - 1.0) < EPS_NON_EDGE) {
                            long double target =
                                (d < 1.0 ? 1.0 - EPS_NON_EDGE
                                         : 1.0 + EPS_NON_EDGE);
                            long double diff = d - target;
                            long double g = 2 * diff / d;
                            gx[i] += g * dx;
                            gy[i] += g * dy;
                            gx[j] -= g * dx;
                            gy[j] -= g * dy;
                        }
                    }

                    if(d < EPS_DISTINCT) {
                        long double diff = d - EPS_DISTINCT;
                        long double g = 2 * diff / d;
                        gx[i] += g * dx;
                        gy[i] += g * dy;
                        gx[j] -= g * dx;
                        gy[j] -= g * dy;
                    }
                }
            }

            for(int i = 0; i < n; i++) {
                x[i] -= lr * gx[i];
                y[i] -= lr * gy[i];
            }

            lr *= LR_DECAY;
        }

        if(verify_solution()) {
            cout << "Yes\n";
            cout << fixed << setprecision(12);
            for(int i = 0; i < n; i++) {
                cout << x[i] << " " << y[i] << "\n";
            }
            return;
        }
    }

    cout << "No\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }
    return 0;
}
```

---

## 4. Python Solution

```python
import sys, time, math, random

EPS_EDGE = 1e-7
EPS_NON_EDGE = 1e-2
EPS_DISTINCT = 1e-2

MAX_COORD = 7.0
TIME_LIMIT = 0.6
LR_START = 0.05
LR_DECAY = 0.999
MAX_ITERS = 10000


def verify(n, adj, xs, ys):
    for i in range(n):
        for j in range(i + 1, n):
            dx = xs[i] - xs[j]
            dy = ys[i] - ys[j]
            d = math.hypot(dx, dy)

            if d < EPS_DISTINCT:
                return False

            if adj[i][j]:
                if abs(d - 1.0) > EPS_EDGE:
                    return False
            else:
                if abs(d - 1.0) < EPS_NON_EDGE:
                    return False

    return True


def solve():
    data = sys.stdin.read().strip().split()
    if not data:
        return
    it = iter(data)
    n = int(next(it))
    m = int(next(it))

    adj = [[False] * n for _ in range(n)]
    for _ in range(m):
        u = int(next(it))
        v = int(next(it))
        adj[u][v] = adj[v][u] = True

    xs = [0.0] * n
    ys = [0.0] * n

    start = time.perf_counter()

    while time.perf_counter() - start < TIME_LIMIT:
        for i in range(n):
            xs[i] = random.uniform(-MAX_COORD, MAX_COORD)
            ys[i] = random.uniform(-MAX_COORD, MAX_COORD)

        lr = LR_START

        for _ in range(MAX_ITERS):
            gx = [0.0] * n
            gy = [0.0] * n

            for i in range(n):
                xi, yi = xs[i], ys[i]
                for j in range(i + 1, n):
                    dx = xi - xs[j]
                    dy = yi - ys[j]
                    d = math.hypot(dx, dy) + 1e-12

                    if adj[i][j]:
                        diff = d - 1.0
                        g = 2.0 * diff / d
                        gx[i] += g * dx
                        gy[i] += g * dy
                        gx[j] -= g * dx
                        gy[j] -= g * dy

                    else:
                        if abs(d - 1.0) < EPS_NON_EDGE:
                            target = (1.0 - EPS_NON_EDGE) if d < 1.0 else (1.0 + EPS_NON_EDGE)
                            diff = d - target
                            g = 2.0 * diff / d
                            gx[i] += g * dx
                            gy[i] += g * dy
                            gx[j] -= g * dx
                            gy[j] -= g * dy

                    if d < EPS_DISTINCT:
                        diff = d - EPS_DISTINCT
                        g = 2.0 * diff / d
                        gx[i] += g * dx
                        gy[i] += g * dy
                        gx[j] -= g * dx
                        gy[j] -= g * dy

            for i in range(n):
                xs[i] -= lr * gx[i]
                ys[i] -= lr * gy[i]

            lr *= LR_DECAY

        if verify(n, adj, xs, ys):
            out = ["Yes"]
            for i in range(n):
                out.append(f"{xs[i]:.12f} {ys[i]:.12f}")
            sys.stdout.write("\n".join(out))
            return

    sys.stdout.write("No")


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

---

## 5. Compressed Editorial

Model vertex coordinates (x_i, y_i) and define distances d_ij. Minimize an "energy" with gradient descent + random restarts:
- For edges, add (d_ij - 1)^2.
- For non-edges, only if |d_ij - 1| < 10^-2, push to boundary 1 ± 10^-2 via (d_ij - target)^2.
- If d_ij < 10^-2, push apart via (d_ij - 10^-2)^2.

Gradient for (d - T)^2 contributes 2(d - T)(p_i - p_j)/d to i and the negative to j.

Repeat from random initial placements until time budget; verify with judge tolerances and print coordinates if valid, else "No".
