**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define sc second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define TASK "main"
#define int ll
const int nmax = 1e5 + 50;
int n,m;
vector<int> adj[nmax];
ll c;
vector<int> component[nmax];
int in[nmax],mn[nmax];
int timer = 0;
vector<int> st;
int com_count=0;
int pos[nmax];
vector<int> comp_adj[nmax];
bool banned[nmax];
void dfs(int u,int parent = 0){
    in[u] = mn[u] = ++timer;
    st.push_back(u);
    for(int v:adj[u]){
        if(v==parent || banned[v]) continue;
        if(!in[v]) dfs(v,u);
        mn[u] = min(mn [u] , mn[v]);
    }
    if(in[u] == mn[u]){
        int v;
        ++ com_count;
        do {
            v = st.back();
            banned[v] = 1;
            pos[v] = com_count;
            component[com_count].push_back(v);
            st.pop_back();
        } while(v!=u);
    }
}
int dfs3(int u,int parent =0){
    int s = 1;
    for(int v:comp_adj[u]){
        if(v!=parent){
            // dfs3(v,u);
            s+= dfs3(v,u);
        }
    }
    return s;
}
int dp[nmax];
bitset<nmax> b,tmp;
bool vis[nmax];
void dfs2(int u,int parent = 0){
    dp[u] = component[u].size();
    vis[u] = 1;
    for(int v:comp_adj[u]){
        if(v!=parent){
            dfs2(v,u);
            dp[u] += dp[v];
        }
    }
    tmp |= (b<<dp[u]);
}
void solve(){
    cin >> n >> m >> c;
    for(int i = 1;i<=m;++i){
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 1;i<=n;i++){
        if(!in[i]){
            dfs(i);
        }
    }
    for(int i = 1;i<=n;i++){
        for(int v:adj[i]){
            if(pos[v] != pos[i])
                comp_adj[pos[i]].push_back(pos[v]);
        }
    }
    b[0] = 1;
    ll ans = -c;
    for(int i = 1;i<=com_count;i++){
        if(!vis[i]){
            // cout << i << '\n';
            int sz = dfs3(i);
            // tmp.reset();
            tmp |= (b<<sz);
            dfs2(i);
            b |= (b<<sz);
            ans += c;
        }
    }
    // cout <<
    ll mnx = 1e18;
    for(int i = 1;i<=n;i++){
        if(tmp[i])
            mnx = min(mnx, ans + i * i + (n-i) * (n-i));
    }
    if(com_count == 1) mnx = -1;
    cout << mnx << '\n';
    for(int i = 1;i<=com_count;++i){
        component[i].clear();
        comp_adj[i].clear();
    }
    for(int i = 1;i<=n;i++) {
        adj[i].clear();
        in[i] = 0;
        mn[i] = 0;
        vis[i] = 0;
        banned[i] = 0;
        dp[i] = 0;
    }
    com_count = 0;
    st.clear();
    tmp.reset();
    b.reset();
    timer = 0;

}

signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    if(fopen(TASK ".inp","r")){
    freopen(TASK ".inp","r",stdin);
    freopen(TASK ".out","w",stdout);
    }
    int t;
    cin >> t;
    while(t--)
        solve();
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4 5 10
1 2
2 3
3 4
4 1
1 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;
#define INF 1e18
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PRINTD(...)                                                            \
  if (debug)                                                                   \
  printf(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MAXN 100005

int n, m, c;
const bool debug = false;
vector<vector<pii>> g;
vector<vector<int>> g2;
vector<int> low, visited, visited2, disc, compSize;
bitset<MAXN> dp[2];
int curtime;
int possible = 0;
int dfs_bridge(int cur, int prev) {
  disc[cur] = curtime++;
  low[cur] = disc[cur];
  compSize[low[cur]] = 1;
  int curCompSize = 1;
  visited[cur] = 1;
  for (pii &to : g[cur]) {
    if (to.first == prev)
      continue;
    if (visited[to.first]) {
      if (low[cur] > disc[to.first]) {
        compSize[low[cur]]--;
        PRINTD("prev low %d, cur low %d, compsize %d\n", low[cur],
               disc[to.first], compSize[low[cur]]);
        low[cur] = disc[to.first];
        compSize[low[cur]]++;
      }
    } else {
      curCompSize += dfs_bridge(to.first, cur);
      if (low[cur] > low[to.first]) {
        compSize[low[cur]]--;
        low[cur] = low[to.first];
        compSize[low[cur]]++;
      }
      if (low[to.first] > disc[cur]) {
        to.second = 1;
        possible = 1;
        PRINTD("FOUND bridge %d %d\n", to.first, cur);
      }
    }
  }
  return curCompSize;
}
void dfs_components(int cur, int prev) {
  PRINTD("CUR %d prev %d\n", cur, prev);
  visited2[cur] = true;
  for (auto to : g[cur]) {

    if (to.first == prev) {
      continue;
    }
    if (!visited2[to.first]) {
      dfs_components(to.first, cur);
    }
    if (to.second == 1) {
      PRINTD("FOUND bridge %d %d\n", to.first, cur);
      PRINTD("FOUND bridge low %d %d\n", low[to.first], low[cur]);
      g2[low[cur]].push_back(low[to.first]);
      g2[low[to.first]].push_back(low[cur]);
    }
  }
}

int dfs_tree(int cur, int prev, int entireCompSize) {
  int cursize = compSize[cur];
  for (int to : g2[cur]) {
    if (to == prev)
      continue;
    PRINTD("TO: %d\n", to);
    cursize += dfs_tree(to, cur, entireCompSize);
  }
  dp[1] |= (dp[0] << cursize);
  dp[1] |= (dp[0] << (entireCompSize - cursize));
  PRINTD("Cursize: %d %d\n", cursize, (entireCompSize - cursize));
  return cursize;
}

void solve() {
  cin >> n >> m >> c;
  g = vector<vector<pii>>(n);
  g2 = vector<vector<int>>(n);
  low = vector<int>(n);
  visited = vector<int>(n, 0);
  visited2 = vector<int>(n, 0);
  disc = vector<int>(n);
  compSize = vector<int>(n);
  dp[0].reset();
  dp[1].reset();
  dp[0][0] = 1;
  dp[1][0] = 1;
  curtime = 0;
  possible = 0;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back({b, 0});
    g[b].push_back({a, 0});
  }
  int compCount = 0;
  int curCompSize;
  for (int i = 0; i < n; i++) {
    if (visited[i])
      continue;
    compCount++;
    curCompSize = dfs_bridge(i, -1);
    dfs_components(i, -1);
    dfs_tree(low[i], -1, curCompSize);
    PRINTD(" cur comp size %d\n", curCompSize);
    dp[0] |= dp[0] << curCompSize;
    dp[1] |= dp[1] << curCompSize;
  }
  for (int i = 0; i < n; i++) {
    PRINTD("%d ", low[i]);
  }
  PRINTD("\ndone with dp\n");
  for (int i = 0; i < n; i++) {
    PRINTD("%d ", compSize[i]);
  }
  PRINTD("\ndone with dp\n");

  ll ans = INF;
  for (int i = 1; i < n; i++) {
    PRINTD("i: %d %d\n", 0 + dp[0][i], 0 + dp[1][i]);
    if (dp[0][i] || dp[1][i]) {
      ans = min(ans, 1ll * i * i + 1ll * (n - i) * (n - i));
    }
  }
  ans += 1ll * (compCount - 1) * c;
  if (!possible && compCount == 1)
    ans = -1;
  if (ans == 5531771272) {
    visited.clear();
    visited = vector<int>(n);
    vi tmp;
    for (int i = 0; i < n; i++) {
      if (!visited[low[i]]) {
        tmp.push_back(low[i]);
      }
      visited[low[i]] = 1;
    }
    for (int x : tmp)
      cout << x << endl;
  }
  cout << ans << endl;
  g.clear();
  g2.clear();
  low.clear();
  visited.clear();
  visited2.clear();
  disc.clear();
  compSize.clear();
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4 3 10
1 2
2 3
3 4
```

### Explanation:
This test case is designed to challenge the algorithm in several ways:

1. **Linear Structure**: The prison cells are connected in a linear fashion, forming a single component. This structure is simple but can expose issues with the code's ability to correctly identify and handle the only possible division point (i.e., the single corridor that can be used to split the prison into two complexes).

2. **Single Division Point**: There is exactly one way to divide the prison into two complexes by removing a single corridor. Specifically, removing the corridor between cell 2 and cell 3 will split the prison into two complexes: {1, 2} and {3, 4}.

3. **High Corridor Cost**: The cost of building a new corridor is set to 10, which is relatively high. This ensures that the algorithm must find the optimal division without building any new corridors, as the cost of building a new corridor would significantly increase the total funding.

4. **Small Scale**: The test case is small enough to be manageable but complex enough to test the algorithm's ability to handle the problem's constraints.

### Expected Output:
The expected output for this test case should be:
```plaintext
20
```
This is because the optimal division is to split the prison into two complexes: {1, 2} and {3, 4}, with a total funding of \(2^2 + 2^2 = 8\). Since no new corridors are built, the total funding remains 8. However, the provided buggy code might fail to correctly identify this division, leading to an incorrect output.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
from functools import cached_property

mod = 10**9+7

class Test:
    def __init__(self, g, c):
        self.n = len(g)
        self.g = g
        self.c = c
    @classmethod
    def parse(cls):
        n,m,c = map(int, input().split())
        g = [[] for _ in range(n)]
        for _ in range(m):
            u,v = map(int, input().split())
            g[u-1].append(v-1)
            g[v-1].append(u-1)
        return cls(g, c)
    @cached_property
    def comps(self):
        tin = [None]*self.n
        low = [None]*self.n
        sz = [1]*self.n
        return [Comp(self.g, u, tin, low, sz) for u in range(self.n) if tin[u] is None]
    @cached_property
    def multicomps(self):
        d = [[0,set()] for _ in range(self.n+1)]
        for comp in self.comps:
            ks = d[comp.sz]
            ks[0] += 1
            ks[1] |= comp.split
        for sz,ks in enumerate(d):
            while ks[0] >= 4:
                ks[0] -= 2
                d[2*sz][0] += 1
        return d
    @cached_property
    def ways(self):
        w = [0]*(self.n+1)
        w[0] = 1
        for sz, (k, _) in enumerate(self.multicomps):
            for _ in range(k):
                for i in range(self.n-sz, -1, -1):
                    if w[i]:
                        w[i+sz] += w[i]
                        w[i+sz] %= mod
        return w
    def solve(self):
        if len(self.comps)==1 and not self.comps[0].split:
            return -1
        for kmax in range(self.n//2, -1, -1):
            if self.ways[kmax]:
                break
        for sz, (_,split) in enumerate(self.multicomps):
            if split:
                w = self.ways.copy()
                for i in range(self.n-sz+1):
                    w[i+sz] -= w[i]
                    w[i+sz] %= mod
                for s in split:
                    for k in range(self.n//2, kmax, -1):
                        if w[k-s]:
                            kmax = k
                            break
        return kmax**2+(self.n-kmax)**2+self.c*(len(self.comps)-1)

class Comp:
    def __init__(self, g, u, tin, low, sz):
        t = 0
        self.split = set()
        q = [(0,None,u,None)]
        while q:
            pc,u,v,i = q.pop()
            if pc == 0:
                low[v] = tin[v] = t
                t += 1
                q.append((1,u,v,0))
            if pc == 1:
                gv = g[v]
                if i < len(gv):
                    q.append((1,u,v,i+1))
                    w = gv[i]
                    if tin[w] is None:
                        q.append((0,v,w,None))
                    elif w is not u:
                        low[v] = min(low[v], tin[w])
                elif u is not None:
                    sz[u] += sz[v]
                    low[u] = min(low[u], low[v])
                    if low[v] == tin[v]:
                        self.split.add(sz[v])
        self.sz = t
        self.split |= {t-k for k in self.split}

for _ in range(int(input())):
    test = Test.parse()
    print(test.solve())

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4 5 1
1 2
2 3
3 4
4 1
1 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
from functools import cached_property

mod = 10**9+7

class Test:
    def __init__(self, g, c):
        self.n = len(g)
        self.g = g
        self.c = c
    @classmethod
    def parse(cls):
        n,m,c = map(int, input().split())
        g = [[] for _ in range(n)]
        for _ in range(m):
            u,v = map(int, input().split())
            g[u-1].append(v-1)
            g[v-1].append(u-1)
        return cls(g, c)
    @cached_property
    def comps(self):
        tin = [None]*self.n
        low = [None]*self.n
        sz = [1]*self.n
        return [Comp(self.g, u, tin, low, sz) for u in range(self.n) if tin[u] is None]
    @cached_property
    def multicomps(self):
        d = [[0,set()] for _ in range(self.n+1)]
        for comp in self.comps:
            ks = d[comp.sz]
            ks[0] += 1
            ks[1] |= comp.split
        for sz,ks in enumerate(d):
            while ks[0] >= 4:
                ks[0] -= 2
                d[2*sz] += 1
        return d
    @cached_property
    def ways(self):
        w = [0]*(self.n+1)
        w[0] = 1
        for sz, (k, _) in enumerate(self.multicomps):
            for _ in range(k):
                for i in range(self.n-sz, -1, -1):
                    if w[i]:
                        w[i+sz] += w[i]
                        w[i+sz] %= mod
        return w
    def solve(self):
        if len(self.comps)==1 and not self.comps[0].split:
            return -1
        for kmax in range(self.n//2, -1, -1):
            if self.ways[kmax]:
                break
        for sz, (_,split) in enumerate(self.multicomps):
            if split:
                w = self.ways.copy()
                for i in range(self.n-sz+1):
                    w[i+sz] -= w[i]
                    w[i+sz] %= mod
                for s in split:
                    for k in range(self.n//2, kmax, -1):
                        if w[k-s]:
                            kmax = k
                            break
        return kmax**2+(self.n-kmax)**2+self.c*(len(self.comps)-1)

class Comp:
    def __init__(self, g, u, tin, low, sz):
        t = 0
        self.split = set()
        def dfs(u, v):
            nonlocal t
            lo = tin[v] = t
            t += 1
            for w in g[v]:
                if tin[w] is None:
                    dfs(v, w)
                    sz[v] += sz[w]
                    lo = min(lo, low[w])
                elif w is not u:
                    lo = min(lo, tin[w])
            if u is None:
                return
            if lo == tin[v]:
                self.split.add(sz[v])
            low[v] = lo
        dfs(None, u)
        self.sz = t
        self.split |= {t-k for k in self.split}

for _ in range(int(input())):
    test = Test.parse()
    print(test.solve())

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5 10 100
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
#include <bits/stdc++.h>

#define f first
#define s second
#define all(x) x.begin(), x.end()
#define pb push_back
#define sz(x) (int)x.size()
#define pii pair<int, int>
#define int long long

using namespace std;

using ll = long long;

const int mod = 998244353;
const int N = (int)100050;
const int M = 10030;
const int inf = (int)2e9;

const int dx[] = {1,  0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, m, c;
vector<int> g[N];
bool used[N];
int divided[N];
int tin[N], tout[N];
int timer;
int fup[N], sz;
unordered_map<int, int> ok[N];
vector<pii> bridges;
int cmp, raz[N], col[N];

void dfs_bridges(int v, int par = 0) {
	divided[v] = 1;
	tin[v] = fup[v] = ++timer;
    sz++;

    raz[cmp]++;
    col[v] = cmp;

	for (int to : g[v]) {
		if (divided[to] == 1 && to != par) {
			fup[v] = min(fup[v], tin[to]);
		} else if (!divided[to]) {
			dfs_bridges(to, v);
			if (fup[to] > tin[v]) {
                ok[v][to] = ok[to][v] = 1;
                bridges.push_back({v, to});
			}
			fup[v] = min(fup[v], fup[to]);
		}
	}

	divided[v] = 2;
}
int cnt[N];
int id, rid[N];
bitset<N> dp[666], d;

int p[N], szp[N];

int get(int v){
    if(v == p[v])
        return v;
    return p[v] = get(p[v]);
}
void unite(int u, int v){
    u = get(u), v = get(v);
    if(u == v)
        return;
    if(szp[u] > szp[v])
        swap(u, v);
    p[u] = v;
    szp[v] += szp[u];
}

vector<int> gt[N];
int s[N];

void dfs(int v){
    s[v] = 1;
    used[v] = 1;
    for(auto to : gt[v]){
        if(!used[to]){
            dfs(to);
            s[v] += s[to];
        }
    }
}
void solve() {
    cin >> n >> m >> c;
    vector<pair<int, int> > edges;
    for(int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        edges.push_back({u, v});
    }
    ll res = LLONG_MAX;
    cmp = 0;
    for(int i = 1; i <= n; i++){
        if(divided[i])
            continue;
        sz = 0;
        cmp++;
        raz[cmp] = 0;

        dfs_bridges(i);

        cnt[sz]++;
    }

    id = 0;
    for(int i = 1; i <= n; i++){
        if(!cnt[i])
            continue;
        id++;
        rid[i] = id;
        cnt[i]--;
        d.reset();
        d[0] = 1;
        // cout << i << " <--- \n";
        for(int j = 1; j <= n; j++){
            int x = cnt[j];
            for(int b = 0; (1 << b) <= x; b++){
                d |= (d << ((1 << b) * j));
                x -= (1 << b);
            }
            d |= (d << x * j);
        }
        cnt[i]++;
        dp[id] = d;
    }

    for(int i = 1; i <= n; i++){
        p[i] = i;
        szp[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(auto to : g[i]){
            if(!ok[i].count(to)){
                unite(i, to);
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(auto to : g[i]){
            if(ok[i].count(to)){
                gt[get(i)].push_back(get(to));
            }
        }
    }

    for(int i = 1; i <= n; i++)
        used[i] = 0;
    for(int i = 1; i <= n; i++){
        if(get(i) != i)
            continue;
        if(used[i])
            continue;
        dfs(i);
    }

    for(auto [u, v] : bridges){
        // cerr << u << " " << v << "\n";
        u = get(u), v = get(v);
        if(s[u] > s[v])
            swap(u, v);
        int sz = raz[col[u]];
        int a = s[u], b = sz - a;
        // cout << a << "  " << b << " " << sz << " <--- \n";
        // cout << rid[sz] << " <--- \n";
        const auto &cur = dp[rid[sz]];
        for(int s = cur._Find_first(); s < sz(cur); s = cur._Find_next(s)){
            int A = (a + s);
            int B = (n - A);
            // cout << A << "  <---- >" << B << "\n";
            if(A && B){
                // cout << A * 1ll * A + B * 1ll * B + (cmp - 1) * c << "\n";
                res = min(res, A * 1ll * A + B * 1ll * B + (cmp - 1) * c);
            }
        }
    }
    {
        d.reset();
        d[0] = 1;
        for(int j = 1; j <= n; j++){
            int x = cnt[j];
            for(int b = 0; (1 << b) <= x; b++){
                d |= (d << ((1 << b) * j));
                x -= (1 << b);
            }
            d |= (d << x * j);
        }
        for(int s = d._Find_first(); s < sz(d); s = d._Find_next(s)){
            int A = s;
            int B = n - A;

            if(A && B)
                res = min(res, A * 1ll * A + B * 1ll * B + (cmp - 1) * c);
        }
    }

    if(res == LLONG_MAX)
        cout << "-1\n";
    else
        cout << res << "\n";

    for(int i = 1; i <= n; i++){
        g[i].clear();
        used[i] = 0;
        ok[i].clear();
        divided[i] = 0;
        gt[i].clear();
        cnt[i] = 0;
    }
    bridges.clear();
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    cin >> tt;
    for(int i = 1; i <= tt; i++) {
        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,answer=0,sum,c,cnt,allsz;
int dfn[200010], low[200010],d[200010];
bool b[200010];
int s[200010];
bool vis[200010];
vector<pair<int,int> >vec[200010];
vector<int>v[200010],sz[200010];
bitset<50005> dp[2][2];
void tarjan(int x, int j){
	dfn[x]=low[x]=++sum;
	for (int i=0;i<vec[x].size();i++){
		if (dfn[vec[x][i].first]==0){
			tarjan(vec[x][i].first,vec[x][i].second);
			if(dfn[x]<low[vec[x][i].first])b[vec[x][i].second]=b[vec[x][i].second^1]=1;
			low[x]=min(low[x],low[vec[x][i].first]);
		}else if(vec[x][i].second!=(j^1))low[x]=min(low[x],dfn[vec[x][i].first]);
	}
}
void dfs(int x, int dep){
	d[x]=dep;
	s[dep]++;
	for (int i=0;i<vec[x].size();i++){
		if(d[vec[x][i].first]||b[vec[x][i].second]) continue;
		dfs(vec[x][i].first,dep);
	}
}
int dfs2(int x){
	int szz=s[x];
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(!vis[v[x][i]]){
			szz+=dfs2(v[x][i]);
		}
	}
	sz[cnt].push_back(szz);
	return szz;
}
signed main(){
	int t;
	cin>>t;
	while(t--){
		answer=0;
		c=0;
		cnt=0;
		allsz=0;
		sum=0;
		memset(dfn,0,sizeof(dfn));
		memset(low,0,sizeof(low));
		memset(b,0,sizeof(b));
		memset(d,0,sizeof(d));
		memset(s,0,sizeof(s));
		memset(vis,0,sizeof(vis));
		cin>>n>>m>>c;
		for(int i=1;i<=n;i++)vec[i].clear();
		for(int i=1;i<=n;i++){
		    v[i].clear();
		    sz[i].clear();
		}
		for (int i=1;i<=m;i++){
			int u,v;
			cin>>u>>v;
		    if(u==v)continue;
		    vec[u].push_back(make_pair(v,i<<1));
		    vec[v].push_back(make_pair(u,i<<1|1));
		}
		for (int i=1;i<=n;i++)if(dfn[i]==0)tarjan(i,0);
		for (int i=1;i<=n;i++){
		    if(d[i]==0){
				answer++;
				dfs(i,answer);
			}
		}
		if(answer==1){
			cout<<-1<<endl;
			continue;
		}
		for(int i=1;i<=n;i++){
			for(int j=0;j<vec[i].size();j++){
				if(d[i]!=d[vec[i][j].first]){
					v[d[i]].push_back(d[vec[i][j].first]);
				}
			}
		}
		cnt=0;
		for(int i=1;i<=2*n;i++)vis[i]=0;
		for(int i=1;i<=answer;i++){
			if(!vis[i]){
				sz[++cnt].clear();
				allsz=dfs2(i);
				int len=sz[cnt].size();
				for(int j=0;j<len;j++)sz[cnt].push_back(allsz - sz[cnt][j]);
			}
		}
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 2; j++){
				dp[i][j].set(0);
			}
		}
		dp[0][0][0] = dp[1][0][0] = 1;
		for(int i = 1; i <= cnt; i++){
			int all = sz[i].size() / 2 - 1;
			dp[0][i % 2] = (dp[0][(i % 2) ^ 1] | (dp[0][(i % 2) ^ 1] << sz[i][all]));
			for(auto szz : sz[i]){
				dp[0][i % 2] |= (dp[1][(i % 2) ^ 1] << szz);
			}
			dp[1][i % 2] = (dp[1][(i % 2) ^ 1] | (dp[1][(i % 2) ^ 1] << sz[i][all]));
		}
		long long ans = 1e18;
		for(int i = n / 2; i >= 0; i--){
			if(dp[0][cnt % 2][i] || dp[1][cnt % 2][i]){
				ans = min(ans, 1ll * (cnt - 1) * c + 1ll * i * i + 1ll * (n - i) * (n - i));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5 4 10
1 2
2 3
3 4
4 5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define inf 9000000000000000000

const ll P = 1000000000001089ll;

void solve() {
  ll n, m, c, cnt = 0, k = -1;
  cin >> n >> m >> c;
  vector<vector<int>> ed(n + 1);
  for (int i = 1, u, v; i <= m; i++) {
    cin >> u >> v;
    ed[u].push_back(v);
    ed[v].push_back(u);
  }

  vector<ll> sz(n + 1), dfn(n + 1), low(n + 1), fa(n + 1), tmp, g(n + 1), num(n + 1), sum_sz;
  vector<bool> f(n + 1);
  vector<vector<ll>> cand(n + 1);

  function<void(int, int)> tarjan = [&](int u, int father) {
    dfn[u] = low[u] = ++cnt;
    sz[u] = 1;
    for (int v : ed[u]) if (v != father) {
        if (!dfn[v]) {
          tarjan(v, u);
          sz[u] += sz[v];
          low[u] = min(low[u], low[v]);
        } else low[u] = min(low[u], dfn[v]);
      }

    if (low[u] == dfn[u]) tmp.push_back(sz[u]);
  };

  g[0] = 1ll;

  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) {
      k++;
      tmp.clear();
      tarjan(i, i);
      num[sz[i]]++;
      cand[sz[i]].push_back(i);
    }
  }

  dfn.clear(), low.clear();
  dfn.resize(n + 1), low.resize(n + 1);

  for (int i = 1; i <= n; i++) {
    while (num[i] >= 3) {
      num[i] -= 2;
      num[2 * i]++;
    }
    while (num[i]--) sum_sz.push_back(i);
  }

  for (int i : sum_sz) {
    for (int j = n; j >= i; j--) g[j] = (g[j] + g[j - i]) % P;
  }

  vector<ll> use, vis(n + 1);

  for (int comp_sz : sum_sz) {
  	if (vis[comp_sz]) continue;
  	vis[comp_sz] = 1;
    vector<ll> now_g = g;
    for (int i = comp_sz; i <= n; i++) now_g[i] = (now_g[i] - now_g[i - comp_sz] + P) % P;

    for (int i : cand[comp_sz]) {
      tmp.clear();
      tarjan(i, i);
      tmp.pop_back();
      int id = lower_bound(sum_sz.begin(), sum_sz.end(), sz[i]) - sum_sz.begin();
      for (int j = 1; j <= sz[i]; j++) num[j] = 0;
      for (int size : tmp) num[size]++;

      for (int j = 1; j <= sz[i]; j++) {
        if (num[j]) use.push_back(j);
      }

      for (int size : use) {
        for (int s = size; s <= n; s++) if (now_g[s - size]) f[s] = 1;
        for (int s = sz[i] - size; s <= n; s++) if (now_g[s - sz[i] + size]) f[s] = 1;
      }
      use.clear();
    }
  }

  ll ans = inf;
  for (ll i = 1; i < n; i++) {
    if (f[i] || g[i]) ans = min(ans, i * i + (n - i) * (n - i));
  }
  if (ans == inf) cout << -1 << '\n';
  else cout << ans + k * c << '\n';
}

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

  int tt = 1;
  cin >> tt;
  while (tt--) solve();

  return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2 1 10
1 2
4 4 5
1 2
2 3
3 4
4 1
6 5 2
1 2
2 3
3 4
4 5
5 6
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
#include "bits/stdc++.h"
#ifndef ALGO
#define DUMP(...)
#endif
using i64 = long long;
template<typename T, typename U>
inline bool enlarge(T& a, U b) {
  return a < b ? (a = b, true) : false;
}
template<typename T, typename U>
inline bool minify(T& a, U b) {
  return a > b ? (a = b, true) : false;
}

namespace power_details {
template<typename T, typename Enable = void>
struct Identity { static constexpr T get() { return T{1}; } };
template<typename T>
struct Identity<T, std::void_t<decltype(T::identity())>> {
  static constexpr T get() { return T::identity(); }
};
}  // namespace power_details

template<typename T,
         typename MulFunc = std::function<T(T,T)>,
         typename SqrFunc = std::function<T(T)>>
constexpr T power(T a, long long b, MulFunc&& mul, SqrFunc&& sqr) {
  T ret = sqr(power_details::Identity<T>::get());
  for (; b; b >>= 1, a = sqr(a)) if (b & 1) ret = mul(ret, a);
  return ret;
}
template<typename T, typename MulFunc = std::function<T(T,T)>>
constexpr T power(T a, long long b, MulFunc&& mul) {
  return power(a, b, std::forward<MulFunc>(mul), [&](T x) { return mul(x, x); });
}
template<typename T, typename IT = T>
constexpr T power(T a, long long b, T mod) {
  return power(a, b, [&mod](T x, T y) { return static_cast<IT>(x) * y % mod; });
}
template<typename T>
constexpr T power(T a, long long b) {
  return power(a, b, [](T x, T y) { return x * y; });
}

template<typename T>
struct PowerTable final : public std::vector<T> {
  PowerTable() = default;
  PowerTable(int n, const T& g)
    : PowerTable(n, g, [](const T& lhs, const T& rhs) -> T { return lhs * rhs; }) {}
  template<typename MulFunc = std::function<T(T,T)>>
  PowerTable(int n, const T& g, MulFunc&& mul) {
    static_assert(sizeof(PowerTable) == sizeof(std::vector<T>), "");
    this->resize(n + 1);
    this->at(0) = power_details::Identity<T>::get();
    for (int i = 1; i < this->size(); ++i) this->at(i) = mul(this->at(i - 1), g);
  }
};

//-#include "power.hpp"

namespace mod_wrapper_details {
template<typename T, typename U, typename Enable = void>
struct HasWrap : std::false_type {};
template<typename T, typename U>
struct HasWrap<T, U, std::void_t<decltype(T::wrap(std::declval<U>()))>> : std::true_type {};
}  // namespace mod_wrapper_details

template<typename Kernel>
class ModWrapper {
 public:
  static constexpr int get_mod() { return Kernel::get_mod(); }
  static void set_mod(int m) { Kernel::set_mod(m); }

  // Implicit conversion is allowed.
  ModWrapper(int v) : v_(wrap(norm(v))) {}
  ModWrapper(long long v) : v_(wrap(norm(v))) {}
  ModWrapper(unsigned int v) : v_(wrap(norm(v))) {}
  ModWrapper(unsigned long long v) : v_(wrap(norm(v))) {}

  ModWrapper() = default;
  ~ModWrapper() = default;

  // Explicit conversion to other type.
  template<typename T>
  explicit operator T() const {
    if constexpr(std::is_same<T, bool>::value) {
      return static_cast<T>(v_);
    } else {
      return static_cast<T>(unwrap(v_));
    }
  }

  int val() const { return unwrap(v_); }
  ModWrapper& operator+=(const ModWrapper& rhs) { Kernel::add(v_, rhs.v_); return *this; }
  ModWrapper& operator-=(const ModWrapper& rhs) { Kernel::sub(v_, rhs.v_); return *this; }
  ModWrapper& operator*=(const ModWrapper& rhs) { Kernel::mul(v_, rhs.v_); return *this; }
  ModWrapper& operator/=(const ModWrapper& rhs) { Kernel::mul(v_, rhs.inv().v_); return *this; }
  ModWrapper operator+(const ModWrapper& rhs) const { ModWrapper ret = *this; return ret += rhs; }
  ModWrapper operator-(const ModWrapper& rhs) const { ModWrapper ret = *this; return ret -= rhs; }
  ModWrapper operator*(const ModWrapper& rhs) const { ModWrapper ret = *this; return ret *= rhs; }
  ModWrapper operator/(const ModWrapper& rhs) const { ModWrapper ret = *this; return ret /= rhs; }
  bool operator==(const ModWrapper& rhs) const { return val() == rhs.val(); }
  bool operator!=(const ModWrapper& rhs) const { return !(*this == rhs); }
  const ModWrapper operator-() const { ModWrapper ret{0}; Kernel::sub(ret.v_, v_); return ret; }
  const ModWrapper& operator++() { Kernel::add(v_, ModWrapper{1}.v_); return *this; }
  const ModWrapper operator++(int) { ModWrapper ret = *this; ++(*this); return ret; }
  const ModWrapper& operator--() { Kernel::sub(v_, ModWrapper{1}.v_); return *this; }
  const ModWrapper operator--(int) { ModWrapper ret = *this; --(*this); return ret; }

  ModWrapper power(long long b) const { return ::power(*this, b); }
  ModWrapper inv() const {
    return power(Kernel::get_mod() - 2);
  }

  std::string to_string() const { return std::string("{") + std::to_string(val()) + "}"; }

 private:
  using StorageType = typename Kernel::StorageType;

  template<typename T>
  static T norm(T v) {
    const int MOD = Kernel::get_mod();
    if constexpr(sizeof(T) > sizeof(MOD)) {
      v %= MOD;
      if (v < 0) v += MOD;
    } else {
      if (v >= MOD) v -= MOD;
      if (v < 0) v += MOD;
      if (v >= MOD || v < 0) {
        v %= MOD;
        if (v < 0) v += MOD;
      }
    }
    return v;
  }

  static constexpr StorageType wrap(int x) {
    if constexpr(mod_wrapper_details::HasWrap<Kernel, StorageType>()) {
      return Kernel::wrap(x);
    } else {
      return static_cast<StorageType>(x);
    }
  }

  static constexpr int unwrap(StorageType x) {
    if constexpr(mod_wrapper_details::HasWrap<Kernel, StorageType>()) {
      return Kernel::unwrap(x);
    } else {
      return static_cast<int>(x);
    }
  }

  StorageType v_{};
};

template<typename Kernel>
std::string to_string(const ModWrapper<Kernel>& v) {
  return v.to_string();
}

//-#include "mod_wrapper.hpp"

namespace integral_details {

template<int MOD>
struct IntegralKernel {
  using StorageType = int;
  static constexpr void add(int& x, int y) { if ((x += y) >= MOD) x -= MOD; }
  static constexpr void sub(int& x, int y) { if ((x += MOD - y) >= MOD) x -= MOD; }
  static constexpr void mul(int& x, int y) { x = static_cast<int64_t>(x) * y % MOD; }
  static constexpr int get_mod() { return MOD; }
};

}  // namespace integral_details

template<int MOD>
using Integral = ModWrapper<integral_details::IntegralKernel<MOD>>;

// const int MOD = 998244353;
// using Mint = Integral<MOD>;

//-#include "mod.hpp"

struct RevertableDsu {
 public:
  std::vector<int> dsu;
  std::vector<int> sz;

  RevertableDsu() = default;

  explicit RevertableDsu(int n) : dsu(n), sz(n, 1) {
    std::iota(dsu.begin(), dsu.end(), 0);
  }

  bool same(int x, int y) {
    x = find(x);
    y = find(y);
    return x == y;
  }

  int find(int x) {
    while (x != dsu[x]) x = dsu[x];
    return x;
  }

  bool merge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (sz[x] < sz[y]) std::swap(x, y);
    modify(sz[x], sz[x] + sz[y]);
    modify(dsu[y], x);
    return true;
  }

  int history_size() const { return history.size(); }

  void revert(int h) {
    while (history.size() > h) {
      history.back().first = history.back().second;
      history.pop_back();
    }
  }

 private:
  void modify(int& a, int b) {
    history.emplace_back(a, a);
    a = b;
  }

  std::vector<std::pair<int&, int>> history;
};

//-#include "revertable_dsu.hpp"

using Mint = Integral<1'000'000'009>;

const i64 inf = 1e18;

i64 sqr(i64 x) { return x * x; }

struct Solver {

  void solve(int ca, std::istream& reader) {
    int N, M, C;
    reader >> N >> M >> C;
    std::vector<std::pair<int, int>> edges;
    RevertableDsu dsu(N);
    for (int i = 0; i < M; ++i) {
      int x, y;
      reader >> x >> y; --x; --y;
      edges.emplace_back(x, y);
      dsu.merge(x, y);
    }
    std::sort(edges.begin(), edges.end(), [&](auto l, auto r) -> bool {
      int p = dsu.find(l.first);
      int q = dsu.find(r.first);
      if (p == q) return false;
      if (dsu.sz[p] != dsu.sz[q]) return dsu.sz[p] > dsu.sz[q];
      return p < q;
    });
    std::vector<int> low(M), high(M);
    for (int i = 0; i < M; ++i) {
      if (i == 0 || dsu.find(edges[i].first) != dsu.find(edges[i - 1].first)) {
        low[i] = i;
      } else {
        low[i] = low[i - 1];
      }
    }
    for (int i = M - 1; i >= 0; --i) {
      if (i + 1 == M || dsu.find(edges[i].first) != dsu.find(edges[i + 1].first)) {
        high[i] = i;
      } else {
        high[i] = high[i + 1];
      }
    }
    int num_conn = 0;
    int single = 0;
    int mx = 0;
    for (int i = 0; i < N; ++i) if (dsu.find(i) == i) {
      ++num_conn;
      enlarge(mx, dsu.sz[i]);
      if (dsu.sz[i] == 1) {
        ++single;
      }
    }
    dsu.revert(0);

    std::vector<Mint> bag{1};

    auto bag_add = [&](int x) -> void {
      if (x * 2 > N) return;
      assert(x > 0);
      bag.resize(bag.size() + x, Mint{});
      for (int i = (int)bag.size() - 1 - x; i >= 0; --i) if (bag[i]) {
        bag[i + x] += bag[i];
      }
    };
    auto bag_del = [&](int x) -> void {
      if (x * 2 > N) return;
      assert(x > 0);
      for (int i = 0; i + x < bag.size(); ++i) if (bag[i]) {
        bag[i + x] -= bag[i];
      }
      bag.resize((int)bag.size() - x, Mint{});
    };

    auto multi_add = [&](int x, int cnt) -> void {
      for (int c = 1; c <= cnt; cnt -= c, c <<= 1) {
        bag_add(x * c);
      }
      if (cnt > 0) {
        bag_add(x * cnt);
      }
    };
    auto multi_del = [&](int x, int cnt) -> void {
      for (int c = 1; c <= cnt; cnt -= c, c <<= 1) {
        bag_del(x * c);
      }
      if (cnt > 0) {
        bag_del(x * cnt);
      }
    };

    auto batch_add = [&](const std::vector<int>& vec) -> void {
      for (int i = 0, j = 1; i < vec.size(); i = j++) {
        while (j < vec.size() && vec[j] == vec[i]) ++j;
        multi_add(vec[i], j - i);
      }
    };
    auto batch_del = [&](const std::vector<int>& vec) -> void {
      for (int i = 0, j = 1; i < vec.size(); i = j++) {
        while (j < vec.size() && vec[j] == vec[i]) ++j;
        multi_del(vec[i], j - i);
      }
    };

    multi_add(1, single);

    const int TARGET_BAR = (N + 1) / 2;
    int target = 0;
    auto update = [&](int x) -> void {
      if (x <= TARGET_BAR) enlarge(target, x);
      if (N - x <= TARGET_BAR) enlarge(target, N - x);
    };
    auto dc = [&](auto self, int l, int r) -> void {
      if (l == r) {
        if (l < M) {
          auto [x, y] = edges[l];
          if (dsu.same(x, y)) return;
          int p = dsu.sz[dsu.find(x)];
          int q = dsu.sz[dsu.find(y)];
          for (int i = std::max({0, (N + 1) / 2 - p - q - 10, target - std::min(p, q)}); i <= TARGET_BAR && i < bag.size(); ++i) if (bag[i]) {
            update(i + p);
            update(i + q);
          }
          for (int i = std::max({0, N - mx - p - q - 10, target - std::min(p, q)}); i <= N - mx && i < bag.size(); ++i) if (bag[i]) {
            update(i + p);
            update(i + q);
          }
        } else {
          for (int i = target; i <= TARGET_BAR && i < bag.size(); ++i) if (bag[i]) {
            update(i);
          }
        }
        return;
      }

      int mid = (l + r) >> 1;
      {
        int h = dsu.history_size();
        std::vector<int> vec;
        for (int i = r; i > mid; --i) if (i < M) {
          auto [x, y] = edges[i];
          dsu.merge(x, y);
          if (low[i] == i) {
            vec.emplace_back(dsu.sz[dsu.find(x)]);
          }
        }
        std::sort(vec.begin(), vec.end());
        batch_add(vec);
        self(self, l, mid);
        batch_del(vec);
        dsu.revert(h);
      }
      {
        int h = dsu.history_size();
        std::vector<int> vec;
        for (int i = l; i <= mid; ++i) {
          auto [x, y] = edges[i];
          dsu.merge(x, y);
          if (high[i] == i) {
            vec.emplace_back(dsu.sz[dsu.find(x)]);
          }
        }
        std::sort(vec.begin(), vec.end());
        batch_add(vec);
        self(self, mid + 1, r);
        batch_del(vec);
        dsu.revert(h);
      }
    };

    dc(dc, 0, M);

    if (target == 0) {
      puts("-1");
    } else {
      i64 result = sqr(target) + sqr(N - target) + 1ll* C * (num_conn - 1);
      printf("%lld\n", result);
    }
  }
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::istream& reader = std::cin;

  int cas = 1;
  reader >> cas;
  for (int ca = 1; ca <= cas; ++ca) {
    auto solver = std::make_unique<Solver>();
    solver->solve(ca, reader);
  }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to focus on edge cases that can highlight issues in the algorithm. Here are the steps to think through this:

1. **Understand the Problem Constraints:**
   - \(2 \leq \sum n \leq 10^5\)
   - \(1 \leq \sum m \leq 5 \times 10^{5}\)
   - \(1 \leq c \leq 10^9\)

2. **Identify Potential Bugs:**
   - The code uses a RevertableDsu to manage the connected components.
   - The sorting and merging process might have issues with edge cases.
   - The bagging mechanism for managing the sizes of components could have bugs.

3. **Construct Edge Cases:**
   - **Single Component Graph:** A graph where all nodes are connected, making it impossible to divide into two complexes.
   - **Multiple Disjoint Components:** A graph with multiple disjoint components, requiring the minimum number of new corridors to connect them.
   - **Graph with a Bridge:** A graph where removing one edge can split the graph into two components.

4. **Generate a Small-Scale Test Input:**
   - We will create a graph with a small number of nodes and edges to ensure it fits within the constraints and is easy to verify.

### Test Input

```plaintext
3
4 5 5
1 2
2 3
3 4
4 1
1 3
6 5 2
1 2
2 3
3 4
4 5
5 6
7 5 4
1 2
2 3
3 4
4 5
5 1
```

### Explanation

1. **Test Case 1:**
   - **Input:** \(4\) nodes, \(5\) edges, \(c = 5\)
   - **Graph:** A cycle graph with an additional edge.
   - **Expected Output:** \(-1\) (impossible to divide into two complexes with exactly one connecting corridor).

2. **Test Case 2:**
   - **Input:** \(6\) nodes, \(5\) edges, \(c = 2\)
   - **Graph:** A path graph.
   - **Expected Output:** \(20\) (divide into two complexes \(\{1, 2, 3\}\) and \(\{4, 5, 6\}\) with no new corridors needed).

3. **Test Case 3:**
   - **Input:** \(7\) nodes, \(5\) edges, \(c = 4\)
   - **Graph:** A cycle graph with one additional node.
   - **Expected Output:** \(33\) (divide into two complexes \(\{1, 2, 3, 4, 5\}\) and \(\{6, 7\}\) with two new corridors needed).

This test input should help expose any issues in the buggy code by covering different types of graph structures and edge cases.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Min-Fund Prison (Hard)
time_limit_ms: 1500
memory_limit_mb: 256
Description: In the hard version, $$$2 \leq \sum n \leq 10^5$$$ and $$$1 \leq \sum m \leq 5 \times 10^{5}$$$

After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of $$$n$$$ prison cells and $$$m$$$ bi-directional corridors. The $$$i^{th}$$$ corridor is from cells $$$u_i$$$ to $$$v_i$$$. A subset of these cells $$$S$$$ is called a complex if any cell in $$$S$$$ is reachable from any other cell in $$$S$$$. Formally, a subset of cells $$$S$$$ is a complex if $$$x$$$ and $$$y$$$ are reachable from each other for all $$$x, y \in S$$$, using only cells from $$$S$$$ on the way. The funding required for a complex $$$S$$$ consisting of $$$k$$$ cells is defined as $$$k^2$$$.

As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into $$$2$$$ complexes with $$$\textbf{exactly one corridor}$$$ connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any $$$2$$$ cells is $$$c$$$.

Due to budget cuts and the ongoing fight against the Death Eaters, you must find the $$$\textbf{minimum total funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Note: The total funding is the sum of the funding required for the $$$2$$$ complexes and the corridors built. If after the division, the two complexes have $$$x$$$ and $$$y$$$ cells respectively and you have built a total of $$$a$$$ corridors, the total funding will be $$$x^2 + y^2 + c \times a$$$. Note that $$$x+y=n$$$.

Input: The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.

The first line of each test case consists of three integers $$$n, m$$$ and $$$c$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5 \times 10^{5}$$$, $$$1 \leq c \leq 10^9$$$)

$$$m$$$ lines follow, each consisting of 2 integers — $$$u_i, v_i$$$ indicating a corridor is present between cells $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$, $$$u_i \neq v_i$$$)

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$5 \times 10^5$$$.

It is guaranteed that there exists at most one corridor between any two cells.

Output: Print the $$$\textbf{minimum funding}$$$ required to divide the prison as per the Ministry's requirements or $$$-1$$$ if no division is possible.

Examples:
input:
4
4 6 5
4 3
2 3
2 4
1 2
4 1
3 1
6 6 2
1 4
2 5
3 6
1 5
3 5
6 5
6 5 7
1 4
2 5
3 6
3 5
6 5
7 5 4
1 4
3 6
3 5
6 5
2 7
output:
-1
20
25
33

Note: In the first test case of the sample input, there is no way to divide the prison according to the Ministry's requirements.

In the second test case, consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{2, 3, 5, 6\}$$$ and $$$\{1, 4\}$$$ cells respectively. There are no new corridors built. The total funding is $$$4^2 + 2^2 = 20$$$. You can verify this is the minimum funding required.

In the third test case, build a corridor between $$$2$$$ and $$$4$$$. Consider the corridor between cells $$$1$$$ and $$$5$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{3, 5, 6\}$$$ and $$$\{1, 2, 4\}$$$ cells respectively. The total funding is $$$3^2 + 3^2 + 7 \times 1 = 25$$$. You can verify this is the minimum funding required.

In the fourth test case, build a corridor between $$$2$$$ and $$$4$$$ and between $$$5$$$ and $$$7$$$. Consider the corridor between cells $$$5$$$ and $$$7$$$ as the connection between the $$$2$$$ complexes consisting of $$$\{1, 2, 4, 7\}$$$ and $$$\{3, 5, 6\}$$$ cells respectively. The total funding is $$$4^2 + 3^2 + 4 \times 2 = 33$$$. You can verify this is the minimum funding required.

Note for all test cases that there may be multiple ways to get the same funding but there is no other division which will have a more optimal minimum funding.

Buggy Code:
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro "<<i<<endl
#define INF 1000000000000000000LL
#define EPS ((ld)0.00000000001)
#define pi ((ld)3.141592653589793)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007;

template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}

class Graph
{
    public:
    ll N;
    vector<vector<ll> > adj;
    vector<ll> visited; //for DFS/BFS
    vector<ll> current; //for CC
    vector<ll> og; //node i points to value og[i]
    vector<vector<ll> > dfs_tree;
    vector<ll> roots;

    Graph() {ll N=0LL;}

    Graph(vector<vector<ll> > ad)
    {
        adj=ad; N=adj.size(); REP(i,0,N) {visited.pb(false);}
    }

    void Reset()
    {
        REP(i,0,N) {visited[i]=false;}
        current.clear();
    }

    void DFS(ll s)
    {
        if(visited[s]) {return;}
        visited[s]=true;
        current.pb(s); //only needed for CC
        REP(i,0,adj[s].size())
        {
            if(!visited[adj[s][i]]) {DFS(adj[s][i]);}
        }
        return;
    }

    void DFS_Tree(ll s)
    {
        if(visited[s]) {return;}
        visited[s]=true;
        REP(i,0,adj[s].size())
        {
            if(!visited[adj[s][i]]) {dfs_tree[s].pb(adj[s][i]); dfs_tree[adj[s][i]].pb(s); DFS_Tree(adj[s][i]);}
        }
        return;
    }

    vector<vector<ll> > CC()
    {
        Reset();
        ll fi=0; ll missing=N; REP(i,0,N) {visited[i]=false;}
        vector<vector<ll> > ans;
        while(missing>0)
        {
            REP(i,fi,N) {if(!visited[i]) {fi=i; break;}}
            current.clear();
            DFS(fi);
            ans.pb(current);
            missing-=current.size();
        }
        return ans;
    }

    vector<Graph> CCG()
    {
        Reset();
        vector<Graph> ans;
        vector<vector<ll> > CC=(*this).CC();
        unordered_map<ll,ll> m;vector<ll> xx; vector<vector<ll> > ad;
        vector<ll> ma;
        REP(cc,0,CC.size())
        {
            m.clear(); ma.clear();
            ad.clear();
            ll NN=CC[cc].size();
            REP(i,0,NN) {ad.pb(xx);}
            REP(i,0,NN) {m[CC[cc][i]]=i; ma[i]=ma[CC[cc][i]];}
            ll a,b;
            REP(i,0,NN)
            {
                a=CC[cc][i];
                REP(j,0,adj[a].size()) {b=adj[a][j]; ad[i].pb(m[b]);}
            }
            Graph H(ad); H.og=ma;
            ans.pb(H);
        }
        return ans;
    }
};

class Tree
{
    public:
    ll N;
    vector<ll> p;
    vector<vector<ll> > sons;
    vector<vector<ll> > adj;
    vector<ll> root; ll curroot;
    vector<bool> visited;
    vector<ll> level; //starting in 0
    vector<ll> sub; //number of nodes in subtree
    vector<vector<ll> > back_edge; //in the case this tree is a DFS-tree
    vector<pl> bridge;
    vector<ll> articulation_point;
    vector<ll> high_be; //highest back_edge per node
    vector<ll> high_sub; //highest back_edge in subtree
	vector<ll> og;

    Tree(vector<vector<ll> > ad, vector<ll> roots)
    {
        N=ad.size(); adj=ad;
        vector<ll> xx; REP(i,0,N) {sons.pb(xx); p.pb(-1); level.pb(0); sub.pb(1LL);}
        VV(visited,N,false); root = roots;
        REP(i,0,root.size()) {curroot = root[i]; DFS_Build(root[i],root[i]);}
    }

    void DFS_Build(ll s, ll par)
    {
        if(s!=curroot) {level[s]=level[par]+1LL;}
        p[s]=par;
        REP(i,0,adj[s].size())
        {
            if(adj[s][i]==par) {continue;}
            sons[s].pb(adj[s][i]);
            DFS_Build(adj[s][i],s);
            sub[s]+=sub[adj[s][i]];
        }
        return;
    }

    void High_Sub(ll s)
    {
        REP(i,0,sons[s].size()) {High_Sub(sons[s][i]);}
        REP(i,0,sons[s].size()) {ll c=sons[s][i]; high_sub[s]=min(high_sub[s],high_sub[c]);}
    }

    void Init_Back_Edge(vector<vector<ll> > be)
    {
        back_edge=be;
        REP(i,0,N) {high_be.pb(level[i]); high_sub.pb(level[i]);}
        REP(i,0,N)
        {
            REP(j,0,back_edge[i].size())
            {
                ll c = back_edge[i][j];
                high_be[i]=min(high_be[i],level[c]);
            }
        }
        REP(i,0,N) {high_sub[i]=high_be[i];}
        REP(i,0,root.size()) {High_Sub(root[i]);}
    }

    void FindBridge()
    {
        REP(i,0,N)
        {
            if(p[i]==i) {continue;}
            if(high_sub[i]==level[i]) {bridge.pb(mp(i,p[i]));}
        }
    }
};

Tree DFS_Tree(Graph G)
{
    vector<ll> xx; REP(i,0,G.N) {G.dfs_tree.pb(xx);}
    G.Reset();
    REP(i,0,G.N)
    {
        if(G.visited[i]) {continue;} G.DFS_Tree(i); G.roots.pb(i);
    }
    Tree T(G.dfs_tree,G.roots);
    vector<vector<ll> > be; REP(i,0,T.N) {be.pb(xx);}
    ll A, B;
    REP(i,0,G.N)
    {
        REP(j,0,G.adj[i].size())
        {
            A = i; B = G.adj[i][j];
            if(T.p[A]==B || T.level[A]<T.level[B]) {continue;}
            be[A].pb(B);
        }
    }
    T.Init_Back_Edge(be);
    return T;
}

vector<vector<bool> > Sum_Set_Cover(vector<ll> a, ll MAX, bool rev)
{
    ll N = a.size(); vector<vector<bool> > ans; vector<bool> xx; VV(xx,MAX+1,false); VV(ans,N,xx);
    if(rev) {reverse(whole(a));}
    REP(i,0,N)
    {
        if(i==0) {ans[0][0]=true; if(a[0]<=MAX) {ans[0][a[0]]=true;} continue;}
        REP(j,0,MAX+1) {if(ans[i-1][j] || (j>=a[i] && ans[i-1][j-a[i]])) {ans[i][j]=true;}}
    }
    if(rev)
    {
        REP(i,0,N/2)
        {
            REP(j,0,MAX+1) {swap(ans[i][j],ans[N-1-i][j]);}
        }
    }
    return ans;
}

typedef vector<int> VI;
double PI = acos(0) * 2;

class complex
{
    public:
        double a, b;
        complex() {a = 0.0; b = 0.0;}
        complex(double na, double nb) {a = na; b = nb;}
        const complex operator+(const complex &c) const
            {return complex(a + c.a, b + c.b);}
        const complex operator-(const complex &c) const
            {return complex(a - c.a, b - c.b);}
        const complex operator*(const complex &c) const
            {return complex(a*c.a - b*c.b, a*c.b + b*c.a);}
        double magnitude() {return sqrt(a*a+b*b);}
        void print() {printf("(%.3f %.3f)\n", a, b);}
};

class FFT
{
    public:
        vector<complex> data;
        vector<complex> roots;
        VI rev;
        int s, n;

        void setSize(int ns)
        {
            s = ns;
            n = (1 << s);
            int i, j;
            rev = VI(n);
            data = vector<complex> (n);
            roots = vector<complex> (n+1);
            for (i = 0; i < n; i++)
                for (j = 0; j < s; j++)
                    if ((i & (1 << j)) != 0)
                        rev[i] += (1 << (s-j-1));
            roots[0] = complex(1, 0);
            complex mult = complex(cos(2*PI/n), sin(2*PI/n));
            for (i = 1; i <= n; i++)
                roots[i] = roots[i-1] * mult;
        }

        void bitReverse(vector<complex> &array)
        {
            vector<complex> temp(n);
            int i;
            for (i = 0; i < n; i++)
                temp[i] = array[rev[i]];
            for (i = 0; i < n; i++)
                array[i] = temp[i];
        }

        void transform(bool inverse = false)
        {
            bitReverse(data);
            int i, j, k;
            for (i = 1; i <= s; i++) {
                int m = (1 << i), md2 = m / 2;
                int start = 0, increment = (1 << (s-i));
                if (inverse) {
                    start = n;
                    increment *= -1;
                }
                complex t, u;
                for (k = 0; k < n; k += m) {
                    int index = start;
                    for (j = k; j < md2+k; j++) {
                        t = roots[index] * data[j+md2];
                        index += increment;
                        data[j+md2] = data[j] - t;
                        data[j] = data[j] + t;
                    }
                }
            }
            if (inverse)
                for (i = 0; i < n; i++) {
                    data[i].a /= n;
                    data[i].b /= n;
                }
        }

        static vector<bool> convolution(vector<bool> aa, vector<bool> bb)
        {
            VI a(aa.size()); VI b(bb.size());
            REP(i,0,aa.size()) {if(aa[i]) {a[i]=1;}}
            REP(i,0,bb.size()) {if(bb[i]) {b[i]=1;}}
            int alen = a.size(), blen = b.size();
            int resn = alen + blen - 1;	// size of the resulting array
            int s = 0, i;
            while ((1 << s) < resn) s++;	// n = 2^s
            int n = 1 << s;	// round up the the nearest power of two

            FFT pga, pgb;
            pga.setSize(s);	// fill and transform first array
            for (i = 0; i < alen; i++) pga.data[i] = complex(a[i], 0);
            for (i = alen; i < n; i++)	pga.data[i] = complex(0, 0);
            pga.transform();

            pgb.setSize(s);	// fill and transform second array
            for (i = 0; i < blen; i++)	pgb.data[i] = complex(b[i], 0);
            for (i = blen; i < n; i++)	pgb.data[i] = complex(0, 0);
            pgb.transform();

            for (i = 0; i < n; i++)	pga.data[i] = pga.data[i] * pgb.data[i];
            pga.transform(true);	// inverse transform
            VI result = VI (resn);	// round to nearest integer
            for (i = 0; i < resn; i++)	result[i] = (int) (pga.data[i].a + 0.5);

            int actualSize = resn - 1;	// find proper size of array
            while (result[actualSize] == 0)
                actualSize--;
            if (actualSize < 0) actualSize = 0;
            result.resize(actualSize+1);
            vector<bool> ans(aa.size(),false);
            REP(i,0,aa.size()) {if(result[i]>0) {ans[i]=true;}}
            return ans;
        }
};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	cout.precision(20);
	ll T; cin>>T;
    REP(t,0,T)
    {
        ll N,M,P; cin>>N>>M>>P; pl cur; vector<vector<ll> > adj; VV(adj,N,{});
        REP(i,0,M)
        {
            cin>>cur.ff>>cur.ss; cur.ff--; cur.ss--; adj[cur.ff].pb(cur.ss); adj[cur.ss].pb(cur.ff);
        }
        Graph G(adj); Tree T = DFS_Tree(G);
        T.FindBridge();
        vector<ll> C; vector<vector<pl> > sep; vector<ll> C_ind;
        vector<ll> thisCC; VV(thisCC,N,-1);
        vector<vector<ll> > CC = G.CC(); REP(i,0,CC.size()) {C.pb(CC[i].size()); REP(j,0,CC[i].size()) {thisCC[CC[i][j]]=i;}}
        ll K = C.size();
        VV(sep,K,{}); ll A,B; ll CC_ind; ll S;
        REP(i,0,T.bridge.size())
        {
            A = T.bridge[i].ff; B = T.bridge[i].ss; CC_ind = thisCC[A];
            ll S = T.sub[A];
            sep[CC_ind].pb({S,C[CC_ind]-S});
        }
        map<ll,ll> m; REP(i,0,K) {m[C[i]]=0;} REP(i,0,K) {m[C[i]]++;}
        map<ll,ll>::iterator it = m.begin();
        ll val, oc; ll newoc;
        while(it!=m.end())
        {
            val = it->ff; oc = it->ss;
            if(oc>=4)
            {
                newoc = (oc-2)/2;
                oc-=(2*newoc);
                m[val]=oc; if(m.find(2LL*val)==m.end()) {m[2*val]=0;} m[2*val]+=newoc;
            }
            it++;
        }
        it=m.begin(); vector<ll> a; while(it!=m.end()) {REP(i,0,it->ss) {a.pb(it->ff);} it++;}
        REP(i,0,K)
        {
            val = (lower_bound(whole(a),C[i]) - a.begin()); C_ind.pb(val);
        }
        vector<vector<bool> > SS_left = Sum_Set_Cover(a,N/2,false); vector<vector<bool> > SS_right = Sum_Set_Cover(a,N/2,true);
        ll L = a.size();
        ll max_div = 0; for(ll i = N/2; i>=0; i--) {if(SS_left[L-1][i]) {max_div=i; break;}}
        long long int ans = ((long long int)P)*(long long int)(K-1LL) + (long long int)max_div*(long long int)max_div + (long long int)(N-max_div)*(long long int)(N-max_div);
        vector<set<ll> > vals; vector<bool> cur_left, cur_right; VV(cur_left,N/2+1,false); VV(cur_right,N/2+1,false);
        REP(i,0,L)
        {
            if(i>0 && a[i]==a[i-1]) {vals.pb((set<ll>){}); continue;}
            if(i==0) {REP(j,0,N/2+1) {cur_left[j]=false;} cur_left[0]=true;}
            else {cur_left = SS_left[i-1];}
            if(i==L-1) {REP(j,0,N/2+1) {cur_right[j]=false;} cur_right[0]=true;}
            else {cur_right = SS_right[i+1];}
            vector<bool> bucket = FFT::convolution(cur_left,cur_right);
            set<ll> thisvals; REP(j,0,N/2 +1) {if(bucket[j]) {thisvals.insert(j);}}
            vals.pb(thisvals);
        }
        ll best; set<ll>::iterator it2; bool is_bridge = false;
        REP(i,0,K)
        {
            ll ind = C_ind[i];
            REP(j,0,sep[i].size())
            {
                is_bridge=true;
                A = sep[i][j].ff; B = sep[i][j].ss;
                it2 = vals[ind].end(); it2--; best = *it2;
                it2 = vals[ind].upper_bound(N/2-A); if(it2!=vals[ind].begin()) {it2--; best=max(best,*it2 + A);}
                it2 = vals[ind].upper_bound(N/2-B); if(it2!=vals[ind].begin()) {it2--; best=max(best,*it2 + B);}
                long long int thisans = (long long int)best*(long long int)best + (long long int)(N-best)*(long long int)(N-best) + (long long int)P*(long long int)(K-1LL);
                ans=min(ans,thisans);
            }
        }
        if(K==1 && !is_bridge) {cout<<-1<<endl; continue;}
        cout<<ans<<endl;
    }
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5 5 1
1 2
2 3
3 4
4 5
5 1
```