**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
//Submission: 1732934934.3770876

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MOD = 998244353;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<pair<int, int>> intervals(n);
        for (int i = 0; i < n; ++i) {
            cin >> intervals[i].first >> intervals[i].second;
        }

        long long total_score = 0;
        for (int i = 1; i < (1 << n); ++i) { // Iterate through all non-empty subsets
            vector<pair<int, int>> subset;
            for (int j = 0; j < n; ++j) {
                if ((i >> j) & 1) {
                    subset.push_back(intervals[j]);
                }
            }

            int min_expansions = 1e9;
            for (int point = 1; point <= n; ++point) { // Try all possible intersection points
                int expansions = 0;
                for (auto interval : subset) {
                    int l = interval.first;
                    int r = interval.second;
                    if (point < l) {
                        expansions += (l - point);
                    } else if (point > r) {
                        expansions += (point - r);
                    }
                }
                min_expansions = min(min_expansions, expansions);
            }
            total_score = (total_score + min_expansions) % MOD;
        }
        cout << total_score << 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
3
3
1 1
2 2
3 3
4
1 1
2 2
3 3
4 4
5
1 1
2 2
3 3
4 4
5 5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 998244353;

// Function to find minimum expansions needed for a subset to have a common point
int getMinExpansions(vector<pair<int,int>>& intervals) {
    if (intervals.empty()) return 0;

    // Find the range to check
    int minR = INT_MAX;
    int maxL = INT_MIN;
    for (auto& p : intervals) {
        minR = min(minR, p.second);
        maxL = max(maxL, p.first);
    }

    // If intervals already have common point
    if (maxL <= minR) return 0;

    // Try each position and find minimum expansions needed
    int minExpansions = INT_MAX;
    for (int pos = 1; pos <= 1000000; pos++) {
        int expansions = 0;
        for (auto& p : intervals) {
            if (pos < p.first)
                expansions += p.first - pos;
            else if (pos > p.second)
                expansions += pos - p.second;
        }
        minExpansions = min(minExpansions, expansions);
        if (pos > maxL + 1) break;
    }
    return minExpansions;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<int,int>> intervals(n);
    for (int i = 0; i < n; i++) {
        cin >> intervals[i].first >> intervals[i].second;
    }

    ll total = 0;
    // Process each subset
    for (int mask = 1; mask < (1 << n); mask++) {
        vector<pair<int,int>> subset;
        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                subset.push_back(intervals[i]);
            }
        }
        total = (total + getMinExpansions(subset)) % MOD;
    }

    cout << total << "\n";
}

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

    int t;
    cin >> t;
    while (t--) {
        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:
To generate a challenging test input that exposes the bug in the provided code, we need to focus on edge cases and scenarios that maximize the failure probability. The code has a nested loop that processes each subset of the intervals, which can be very inefficient for large inputs. However, since we are asked to generate a small-scale test input, we can focus on specific edge cases that are likely to cause issues.

### Step-by-Step Analysis:

1. **Single Planet Case**:
   - If there is only one planet, the score should be 0 because the planet is already vulnerable.
   - Test input: `1 1 1`

2. **Non-Intersecting Intervals**:
   - If the intervals do not intersect, the code should correctly calculate the minimum expansions needed to make them intersect.
   - Test input: `3 1 1 2 2 3 3`

3. **Partially Overlapping Intervals**:
   - If the intervals partially overlap, the code should correctly calculate the minimum expansions needed to make them fully intersect.
   - Test input: `3 1 2 2 3 3 4`

4. **Fully Overlapping Intervals**:
   - If the intervals fully overlap, the score should be 0.
   - Test input: `2 1 2 1 2`

5. **Edge Case with Maximum Expansions**:
   - If the intervals are far apart, the code should correctly calculate the maximum number of expansions needed.
   - Test input: `2 1 1 1000000 1000000`

### Chosen Test Input:
Based on the analysis, the following test input will cover a variety of edge cases and is small enough to be valid:

```plaintext
3
1
1 1
3
1 1
2 2
3 3
2
1 1
1000000 1000000
```

### Explanation:
- **Test Case 1**: Single planet with interval `[1, 1]`. The score should be 0.
- **Test Case 2**: Three planets with intervals `[1, 1]`, `[2, 2]`, and `[3, 3]`. The score should be 2 (one expansion for each of the first two planets).
- **Test Case 3**: Two planets with intervals `[1, 1]` and `[1000000, 1000000]`. The score should be 999999 (expanding one planet to cover the other).

This test input should effectively expose any issues with the code's handling of different interval configurations and edge cases.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
#include <bits/stdc++.h>
#define MOD 998244353
static char buf[1000000],*paa=buf,*pd=buf;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline int read(void){
	register int x(0);register char c(getchar());
	while(c<'0'||c>'9'){c=getchar();}
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x;
}
inline int pw(int a,int b) {
	int as=1;
	while(b) {
		if(b&1) as=1ll*as*a%MOD;
		a=1ll*a*a%MOD;
		b>>=1;
	}
	return as;
}
inline int ni(int a) {
	return pw(a,MOD-2);
}
int T,N,v1[1000009],v2[1000009],p[1000009],iv[1000009],q1,q2,su;
inline int C(int a,int b) {
	if(a<b) return 0;
	return 1ll*p[a]*iv[b]%MOD*iv[a-b]%MOD;
}
void er1() {
	su=(su+C(q1-1,q2));
	if(su%2==0) su/=2;
	else su=(1ll*su+MOD)/2;
	q1--;
}
void is1() {
	su=(1ll*MOD+su+su-C(q1,q2))%MOD;
	q1++;
}
void is2() {
	su=(su+C(q1,q2+1))%MOD;
	q2++;
}
signed main(void) {
	T=read();
	p[0]=1;
	for(int i=1;i<=1000000;i++) p[i]=1ll*p[i-1]*i%MOD;
	iv[1000000]=ni(p[1000000]);
	for(int i=999999;i>=0;i--) iv[i]=1ll*iv[i+1]*(i+1)%MOD;
	while(T--) {
		N=read();
		int ans=0;
		for(int i=1;i<=N;i++) v1[i]=v2[i]=0;
		for(int i=1;i<=N;i++) {
			int l=read(),r=read();
			v1[l]++;
			v2[r]++;
			ans=(ans+l-1)%MOD;
		}
		ans=1ll*ans*pw(2,N-1)%MOD;
		for(int i=1;i<=N;i++) {
			v2[i]+=v2[i-1];
		}
		for(int i=N-1;i>=1;i--) {
			v1[i]+=v1[i+1];
		}
		q1=0,q2=-1;
		su=0;
		for(int i=N-1;i>=1;i--) {
			int x=v2[i],y=v1[i+1],aqs=0;
			while(x+y-1<q1) {
				er1();
			}
			while(x+y-1>q1) {
				is1();
			}
			while(q2<y-1) {
				is2();
			}
			int a2=su;
			aqs=(aqs+1ll*x*a2)%MOD;
			aqs=(aqs+1ll*(MOD-y)*(a2+C(x+y-1,y)))%MOD;
			ans=(ans+1ll*aqs*pw(2,N-x-y))%MOD;
		}
		printf("%d\n",ans);
	}
}

**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
3
1 1
1 1
1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
def sum_of_scores(planets):
    MOD = 998244353
    n = len(planets)
    total_score = 0

    # Iterate through all non-empty subsets using bitmask
    for mask in range(1, 1 << n):
        L = float('-inf')
        R = float('inf')

        # Calculate L and R for the current subset
        for i in range(n):
            if mask & (1 << i):  # If the i-th planet is included in the subset
                l_i, r_i = planets[i]
                L = max(L, l_i)
                R = min(R, r_i)

        # Calculate the number of expansions needed
        if L > R:
            expansions = L - R
        else:
            expansions = 0

        # Add the score of this subset to the total score
        total_score = (total_score + expansions) % MOD

    return total_score

t = int(input())
for i in range(t):
    n = int(input())
    planets = []
    for j in range(n):
        planets.append([int(x) for x in input().split()])
    result = sum_of_scores(planets)
    print(result)  # Output the result

**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
3
1 1
2 2
3 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
import java.util.*;
import java.io.*;

public class OrangutansDestruction {
    private static final int MOD = 998244353;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        StringBuilder output = new StringBuilder();

        while (t-- > 0) {
            int n = Integer.parseInt(br.readLine());
            int[][] intervals = new int[n][2];

            for (int i = 0; i < n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine());
                intervals[i][0] = Integer.parseInt(st.nextToken());
                intervals[i][1] = Integer.parseInt(st.nextToken());
            }

            // Calculate the total score for the current test case
            long totalScore = calculateTotalScore(intervals);
            output.append(totalScore).append("\n");
        }

        System.out.print(output);
    }

    private static long calculateTotalScore(int[][] intervals) {
        int n = intervals.length;
        long totalScore = 0;

        // Sort the intervals based on left endpoint
        Arrays.sort(intervals, Comparator.comparingInt(a -> a[0]));

        // We use a bitmask to generate all subsets
        for (int mask = 1; mask < (1 << n); mask++) {
            int maxL = Integer.MIN_VALUE;
            int minR = Integer.MAX_VALUE;
            long expansions = 0;
            boolean validSubset = true;

            for (int j = 0; j < n; j++) {
                if ((mask & (1 << j)) != 0) {
                    maxL = Math.max(maxL, intervals[j][0]);
                    minR = Math.min(minR, intervals[j][1]);
                }
            }

            // If they don't intersect, calculate expansions
            if (maxL > minR) {
                expansions = maxL - minR; // Required expansions to intersect
            }

            totalScore = (totalScore + expansions) % MOD;
        }

        return totalScore;
    }
}

**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
3
1 1
2 2
3 3
4
1 1
2 2
3 3
4 4
5
1 1
2 2
3 3
4 4
5 5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
import java.util.Scanner;
public class TheDestructionOfTheUniverse {
    static final int MOD = 998244353;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            int[][] planets = new int[n][2];
            for (int j = 0; j < n; j++) {
                planets[j][0] = scanner.nextInt();
                planets[j][1] = scanner.nextInt();
            }
            long totalScore = 0;
            for (int mask = 1; mask < (1 << n); mask++) {
                int lMax = Integer.MIN_VALUE;
                int rMin = Integer.MAX_VALUE;
                int expansions = 0;
                for (int j = 0; j < n; j++) {
                    if ((mask & (1 << j)) != 0) {
                        lMax = Math.max(lMax, planets[j][0]);
                        rMin = Math.min(rMin, planets[j][1]);
                    }
                }
                if (lMax > rMin) {
                    expansions = (lMax - rMin);
                }
                totalScore = (totalScore + expansions) % MOD;
            }
            result.append(totalScore).append("\n");
        }
        System.out.print(result);
        scanner.close();
    }
}

**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
3
1 2
2 3
3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod=998244353;
struct node{
	ll l,r;
	int id;
	node(ll l_,ll r_,int id_){
		l=l_,r=r_,id=id_;
	}
	node(){}
}a[1000005],b[1000005],c[1000005];
int n,T;
ll s1[1000005],s2[1000005],fac[1000005],ifac[1000005],pw[1000005];
ll ksm(ll a,ll m,ll p){
	ll ans=1;
	while(m){
		if(m&1)ans=ans*a%p;
		a=a*a%p;
		m>>=1;
	}
	return ans;
}
bool cmp1(node x,node y){
	if(x.l==y.l)return x.id>y.id;
	return x.l>y.l;
}
bool cmp2(node x,node y){
	if(x.r==y.r)return x.id<y.id;
	return x.r<y.r;
}
ll C(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return fac[n]*ifac[n-m]%mod*ifac[m]%mod;
}
ll solve1(int n,int m){
	return (C(n+m+1,m)-C(n+m,m)+mod)%mod;
}
ll solve2(int n,int m){
	return C(n+m,m);
}
ll solve3(int n,int m){
	return (C(n+m+2,m)-2*C(n+m+1,m)%mod+mod+C(n+m,m))%mod;
}
int main(){
	scanf("%d",&T);
	fac[0]=pw[0]=1;
	for(int i=1;i<=1e6;i++)fac[i]=fac[i-1]*i%mod,pw[i]=pw[i-1]*2%mod;
	ifac[1000000]=ksm(fac[1000000],mod-2,mod);
	for(int i=1e6;i;i--)ifac[i-1]=ifac[i]*i%mod;
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%d%d",&a[i].l,&a[i].r),a[i].id=i,b[i]=a[i],c[i]=a[i];
		sort(a+1,a+1+n,cmp1);
		sort(b+1,b+1+n,cmp2);
		for(int i=1;i<=n;i++){
			s1[i]=(s1[i-1]+a[i].l)%mod;
		}
		for(int i=1;i<=n;i++){
			s2[i]=(s2[i-1]+b[i].r)%mod;
		}
		ll ans=0;
		for(int i=1;i<=n;i++){
			int p1=lower_bound(a+1,a+1+n,node(c[i].l,0,i),cmp1)-a-1;
			int p2=lower_bound(b+1,b+1+n,node(0,c[i].l,i),cmp2)-b-1;
			int res=n-1-p1-p2;
//			cout<<p1<<" "<<p2<<endl;
			ans=(ans+s1[p1]*solve1(p1-1,p2)%mod*pw[res]-s2[p2]*solve1(p2-1,p1)%mod*pw[res]%mod+mod)%mod;
//			for(int j=1;j<=min(p1,p2);j++){
//				ans=(ans+(s1[p1]*C(p1-1,j-1)%mod*C(p2,j)%mod-s2[p2]*C(p2-1,j-1)%mod*C(p1,j)%mod+mod)*pw[res])%mod;
//			}
			p1=lower_bound(a+1,a+1+n,node(c[i].r,0,i),cmp1)-a-1;
			p2=lower_bound(b+1,b+1+n,node(0,c[i].r,i),cmp2)-b-1;
			res=n-1-p1-p2;
			ans=(ans-c[i].r*solve1(p2,p1)%mod*pw[res]+mod+s1[p1]*solve2(p1-1,p2)%mod*pw[res]-s2[p2]*solve3(p2-1,p1)%mod*pw[res]%mod+mod)%mod;
//			for(int j=1;j<=min(p1,p2+1);j++){
//				ans=(ans+(s1[p1]*C(p1-1,j-1)%mod*C(p2,j-1)%mod-(s2[p2]*C(p2-1,j-2)+c[i].r*C(p2,j-1))%mod*C(p1,j)%mod+mod)*pw[res])%mod;
//			}
		}
		printf("%lld\n",ans);
	}
	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
3
1 1
1 2
2 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

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

using namespace std;

const int N = 2000005, mo = 998244353;

int t, n, l[N], r[N], sl[N], sr[N], fac[N], inv[N], power[N], ans;

int C(int n, int m)
{
    if (n < m)
        return 0;
    return 1ll * fac[n] * inv[m] % mo * inv[n-m] % mo;
}

int quick_power(int x, int y)
{
    if (!y)
        return 1;
    int mid = quick_power(x, y>>1);
    mid = 1ll * mid * mid % mo;
    if (y & 1)
        mid = 1ll * x * mid % mo;
    return mid;
}

void work()
{
    scanf("%d", &n);
    for (int i = 0; i <= n+1; ++i)
        sl[i] = sr[i] = 0;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d%d", &l[i], &r[i]);
        sl[l[i]]++;
        sr[r[i]]++;
    }
    fac[0] = inv[0] = power[0] = 1;
    for (int i = 1; i <= 2*n; ++i)
    {
        fac[i] = 1ll * fac[i-1] * i % mo;
        inv[i] = quick_power(fac[i], mo-2);
        power[i] = 2 * power[i-1] % mo;
    }
    for (int i = 1; i <= n; ++i)
        sr[i] += sr[i-1];
    for (int i = n; i; --i)
        sl[i] += sl[i+1];

    ans = 0;
    for (int i = 1, sum = 1, p = 0, q = 0; i <= n; ++i)
        if (sr[i] > sr[i-1])
        {
            int x = sr[i-1], y = sl[i+1];
            y += x;
            swap(x, y);
            for (; p < x; ++p)
                sum = (2ll * sum - C(p, q) + mo) % mo;
            for (; p > x; --p)
                sum = 1ll * (sum + C(p-1, q)) * inv[2] % mo;

            for (; q < y; ++q)
                sum = (sum + C(p, q+1)) % mo;
            for (; q > y; --q)
                sum = (sum - C(p, q) + mo) % mo;

            ans = ((ans - 1ll * (power[sr[i] - sr[i-1]] - 1) * i % mo * power[n-sl[i+1]-sr[i]] % mo * (power[x] - sum + mo)) % mo + mo) % mo;
        }

    for (int i = 1, sum = 1, p = 0, q = 0; i <= n; ++i)
        if (sl[i] > sl[i+1])
        {
            int x = sr[i-1], y = sl[i+1];
            x += y;
            for (; p < x; ++p)
                sum = (2ll * sum - C(p, q) + mo) % mo;
            for (; p > x; --p)
                sum = 1ll * (sum + C(p-1, q)) * inv[2] % mo;

            for (; q < y; ++q)
                sum = (sum + C(p, q+1)) % mo;
            for (; q > y; --q)
                sum = (sum - C(p, q) + mo) % mo;

            ans = ((ans + 1ll * (power[sl[i] - sl[i+1]] - 1) * i % mo * power[n-sl[i] - sr[i-1]] % mo * (power[x] - sum + mo)) % mo + mo) % mo;
        }

    printf("%d\n", ans);
}

int main()
{
    //freopen("data.in", "r", stdin);
    for (scanf("%d", &t); t--; work());
    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
2
3
1 1
2 2
3 3
4
1 1
2 2
3 3
4 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <vector>
#include <bitset>
#include <stack>
#include <list>
#include <iterator>
#include <complex>
#include <string>
#include <tuple>
#include <array>
#include <valarray>
#include <regex>
#include <random>
#include <cassert>

using namespace std;

typedef long long ll;

typedef long long ll;
const int M = 998244353;
const int FACTN = 3000000 + 7;

int add(int a, int b) {
  a += b;
  if (a >= M) return a - M;
  if (a < 0) return a + M;
  return a;
}

int mul(int a, int b) {
  return a * (ll)b % M;
}

int add(int a, int b, int c) {
  return add(add(a, b), c);
}

int mul(int a, int b, int c) {
  return mul(mul(a, b), c);
}

int add(int a, int b, int c, int d) {
  return add(add(a, b, c), d);
}

int mul(int a, int b, int c, int d) {
  return mul(mul(a, b, c), d);
}

int add(int a, int b, int c, int d, int e) {
  return add(add(a, b, c, d), e);
}

int mul(int a, int b, int c, int d, int e) {
  return mul(mul(a, b, c, d), e);
}

int add(int a, int b, int c, int d, int e, int f) {
  return add(add(a, b, c, d, e), f);
}

int mul(int a, int b, int c, int d, int e, int f) {
  return mul(mul(a, b, c, d, e), f);
}

int add(int a, int b, int c, int d, int e, int f, int g) {
  return add(add(a, b, c, d, e, f), g);
}

int mul(int a, int b, int c, int d, int e, int f, int g) {
  return mul(mul(a, b, c, d, e, f), g);
}

int add(int a, int b, int c, int d, int e, int f, int g, int h) {
  return add(add(a, b, c, d, e, f, g), h);
}

int mul(int a, int b, int c, int d, int e, int f, int g, int h) {
  return mul(mul(a, b, c, d, e, f, g), h);
}

int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b /= 2;
  }
  return r;
}

int dv(int a, int b) {
  return mul(a, pw(b, M - 2));
}

void addup(int& a, int b) {
  a = add(a, b);
}

void mulup(int& a, int b) {
  a = mul(a, b);
}

void dvup(int& a, int b) {
  a = dv(a, b);
}

int fact[FACTN], ifact[FACTN];

void computeFACT() {
  fact[0] = 1;
  for (int i = 1; i < FACTN; i++) fact[i] = mul(fact[i - 1], i);
  ifact[FACTN - 1] = dv(1, fact[FACTN - 1]);
  for (int i = FACTN - 2; i >= 0; i--) ifact[i] = mul(ifact[i + 1], i + 1);
}

int comb(int n, int k) {
  if (k > n) {
    return 0;
  }
  assert(0 <= k && k <= n && n < FACTN);
  return mul(fact[n], mul(ifact[k], ifact[n - k]));
}
const int N = (int)1e6 + 7;

struct T {
  int l, r;
};

int n;
T v[N];
int tl[N];
int tr[N];
int inv2[N];
pair<int, int> vl[N];
pair<int, int> vr[N];
int steps = 0;
void mv(int& bg, int& stop, int& val, int bg2, int stop2) {
  if (bg == -1) {
    val = 0;
    bg = bg2;
    stop = stop2;
    for (int i = 0; i <= stop; i++) {
      addup(val, comb(bg, i));
    }
  }
  else {
    steps += abs(bg - bg2);
    steps += abs(stop - stop2);
    assert(steps < (int)1e7);
    while (bg < bg2) {
      mulup(val, 2);
      addup(val, -comb(bg, stop));
      bg++;
    }
    while (bg > bg2) {
      bg--;
      if (stop <= bg) {
        addup(val, comb(bg, stop));
      }
      mulup(val, inv2[1]);
    }
    assert(bg == bg2);
    while (stop < stop2) {
      addup(val, comb(bg, ++stop));
    }
    while (stop > stop2) {
      addup(val, -comb(bg, stop--));
    }
  }
  assert(bg == bg2);
  assert(stop == stop2);
}
signed main() {
#ifdef ONPC
  FILE* stream;
  freopen_s(&stream, "input.txt", "r", stdin);
#else
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
#endif

  computeFACT();

  inv2[0] = 1;
  inv2[1] = dv(1, 2);
  for (int i = 2; i < N; i++) {
    inv2[i] = mul(inv2[i - 1], inv2[1]);
  }

  int tt;
  cin >> tt;
  while (tt--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> v[i].l >> v[i].r;
      vl[i] = { v[i].l, i };
      vr[i] = { v[i].r, i };
    }
    int total = 0;
    for (int it = 1; it <= 2; it++) {
      int bg = -1, stop = -1, val = 0;
      for (int i = 1; i <= n; i++) {
        vl[i] = { v[i].l, -i };
        vr[i] = { v[i].r, i };
      }
      sort(vr + 1, vr + n + 1);
      for (int i = 1; i <= n; i++) {
        tr[vr[i].second] = i - 1;
      }
      sort(vl + 1, vl + n + 1);
      reverse(vl + 1, vl + n + 1);
      int p = 0;
      for (int i = n; i >= 1; i--) {
        while (p + 1 <= n && vl[p + 1] > vr[i]) {
          p++;
        }
        tl[vr[i].second] = p;
      }
      for (int j = 1; j <= n; j++) {
        mv(bg, stop, val, tr[j] + tl[j], tr[j]);
        addup(total, mul(add(pw(2, tr[j] + tl[j]), -val), add(0, -v[j].r), pw(2, n - 1 - tr[j] - tl[j])));
      }
      for (int i = 1; i <= n; i++) {
        swap(v[i].l, v[i].r);
        v[i].l = add(0, -v[i].l);
        v[i].r = add(0, -v[i].r);
      }
    }
    cout << total << "\n";
  }

  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:
To create a challenging test input that exposes bugs in the given code, we need to focus on edge cases and scenarios that maximize the failure probability. Here are the steps to think through this:

1. **Edge Cases:**
   - Single planet with a small interval.
   - Multiple planets with overlapping intervals.
   - Multiple planets with non-overlapping intervals.
   - Planets with intervals that are very close to each other but do not overlap.

2. **Maximizing Failure Probability:**
   - Test cases where the intervals are just one unit apart.
   - Test cases with a large number of planets but small intervals.
   - Test cases with intervals that require the minimum number of expansions to overlap.

3. **Small-Scale Test Input:**
   - We need to create a test input that is small enough to be manageable but complex enough to challenge the algorithm.

Given these considerations, let's create a test input:

```plaintext
1
4
1 2
2 3
3 4
4 5
```

This test input includes:
- 4 planets with intervals that are just one unit apart from each other.
- This setup ensures that the algorithm must handle the expansion of intervals to find the minimum number of operations required to make the intervals overlap.

This test case is small but complex enough to expose potential issues in the algorithm's handling of intervals that are close but do not overlap.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <ctime>
#include <cstdlib>
#define pii pair<int,int>
#define mp make_pair
#define pb emplace_back
#define debug() cout<<"qwq"<<endl
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull;
const int DMAX = 1000000 + 5;
const double INF = 1e9;
const int MOD = 998244353;
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template<class T> inline void read(T &x){
    T f=1; x=0; char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch<='9' && ch>='0'){ x=x*10+ch-'0';ch=getchar(); }
    x*=f;
}
int qpow(int a, int b, int p){
    int t = 1;
    while(b){
        if(b & 1) t = 1ll * t * a % p;
        b >>= 1;
        a = 1ll * a * a % p;
    }
    return t;
}
int T;
int n;
int t[DMAX];
int jc[DMAX], jcinv[DMAX];
int C(int x, int y){
    if(x < y) return 0;
    return 1ll * jc[x] * jcinv[y] % MOD * jcinv[x - y] % MOD;
}
struct node{
    int l, r;
};
node a[DMAX];
int h[DMAX], g[DMAX];
int pre[DMAX];
int dx, dy;
int val, inv2;
void calc(int x, int y){
    if(dx == -1 && dy == -1){
        val = 0;
        for(int i = 0; i <= y; i ++){
            val = (0ll + val + C(x, i)) % MOD;
        }
        dx = x, dy = y;
        return ;
    }
    while(dx < x){
        val = (0ll + 2ll * val % MOD + MOD - C(dx, dy)) % MOD;
        dx ++;
    }
    while(dx > x){
        val = (0ll + val + C(dx - 1, dy)) % MOD;
        val = 1ll * val * inv2 % MOD;
        dx --;
    }
    while(dy < y){
        val = (0ll + val + C(dx, dy + 1)) % MOD;
        dy ++;
    }
    while(dy > y){
        val = (0ll + val + MOD - C(dx, dy)) % MOD;
        dy --;
    }
}
void solve(){
    read(n);
    int ans = 0;
    dx = dy = -1, val = 0;
    for(int i = 1; i <= n; i++){
        read(a[i].l), read(a[i].r);
    }
    pre[0] = 0, pre[n + 1] = 0;
    for(int i = 1; i <= n; i++) pre[a[i].r] ++;
    for(int i = 1; i <= n; i++) pre[i] += pre[i - 1];
    for(int i = 1; i <= n; i++) h[i] = pre[a[i].r - 1];
    for(int i = 1; i <= n; i++) pre[i] = 0;
    for(int i = 1; i <= n; i++) h[i] += pre[a[i].r], pre[a[i].r] ++;
    for(int i = 1; i <= n; i++) pre[i] = 0;

    for(int i = 1; i <= n; i++) pre[a[i].l] ++;
    for(int i = n; i >= 1; i--) pre[i] += pre[i + 1];
    for(int i = 1; i <= n; i++) g[i] = pre[a[i].r + 1];
    for(int i = 1; i <= n; i++) pre[i] = 0;

    for(int i = 1; i <= n; i++){
        int temp = (0ll - a[i].r + MOD) % MOD;
        temp = 1ll * temp * t[n - 1 - h[i] - g[i]] % MOD;
        calc(h[i] + g[i], h[i]);
        int now = (0ll + t[h[i] + g[i]] + MOD - val) % MOD;
        ans = (0ll + ans + 1ll * temp * now % MOD) % MOD;
    }
  //  cout<<ans<<endl;
    pre[0] = 0, pre[n + 1] = 0;
    for(int i = 1; i <= n; i++) pre[a[i].r] ++;
    for(int i = 1; i <= n; i++) pre[i] += pre[i - 1];
    for(int i = 1; i <= n; i++) h[i] = pre[a[i].l - 1];
    for(int i = 1; i <= n; i++) pre[i] = 0;

    for(int i = 1; i <= n; i++) pre[a[i].l] ++;
    for(int i = n; i >= 1; i--) pre[i] += pre[i + 1];
    for(int i = 1; i <= n; i++) g[i] = pre[a[i].l + 1];
    for(int i = 1; i <= n; i++) pre[i] = 0;
    for(int i = 1; i <= n; i++) g[i] += pre[a[i].l], pre[a[i].l] ++;
    for(int i = 1; i <= n; i++) pre[i] = 0;

    for(int i = 1; i <= n; i++){
        int temp = a[i].l;
       // cout<<a[i].l <<" "<<a[i].r<<" "<<h[i] + g[i]<<endl;
        temp = 1ll * temp * t[n - 1 - h[i] - g[i]] % MOD;
        calc(h[i] + g[i], g[i]);
        int now = (0ll + t[h[i] + g[i]] + MOD - val) % MOD;
        ans = (0ll + ans + 1ll * temp * now % MOD) % MOD;
    }

    cout<<ans<<endl;
}
int main(){
    jc[0] = 1;
    for(int i = 1; i <= 1000000; i++){
        jc[i] = 1ll * jc[i - 1] * i % MOD;
    }
    jcinv[1000000] = qpow(jc[1000000], MOD - 2, MOD);
    for(int i = 1000000 - 1; i >= 0; i --){
        jcinv[i] = 1ll * jcinv[i + 1] * (i + 1) % MOD;
    }
    t[0] = 1;
    for(int i = 1; i <= 1000000; i++){
        t[i] = 1ll * t[i - 1] * 2 % MOD;
    }
    inv2 = qpow(2, MOD - 2, MOD);
    read(T);
    while(T--){
        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
1
3
1 2
2 3
3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
MOD = 998244353

def min_expansions(intervals):
    n = len(intervals)
    dp = [[float('inf')] * (n + 1) for _ in range(1 << n)]

    # Initialize for single intervals
    for i in range(n):
        l, r = intervals[i]
        for k in range(l, r + 1):
            dp[1 << i][k] = 0

    # Fill DP table
    for mask in range(1, 1 << n):
        for i in range(n):
            if mask & (1 << i):
                continue
            new_mask = mask | (1 << i)
            l, r = intervals[i]
            for k in range(1, n + 1):
                if dp[mask][k] != float('inf'):
                    new_l, new_r = max(l, k), min(r, k)
                    if new_l <= new_r:
                        dp[new_mask][k] = min(dp[new_mask][k], dp[mask][k])
                    else:
                        dp[new_mask][k] = min(dp[new_mask][k], dp[mask][k] + min(abs(l - k), abs(r - k)))

    # Calculate the sum of scores for all non-empty subsets
    total_score = 0
    for mask in range(1, 1 << n):
        min_score = min(dp[mask])
        total_score += min_score
        total_score %= MOD

    return total_score

def main():
    import sys
    input = sys.stdin.read
    data = input().split()

    index = 0
    t = int(data[index])
    index += 1
    results = []

    for _ in range(t):
        n = int(data[index])
        index += 1
        intervals = []
        for _ in range(n):
            l = int(data[index])
            r = int(data[index + 1])
            index += 2
            intervals.append((l, r))
        results.append(min_expansions(intervals))

    for res in results:
        print(res)

if __name__ == "__main__":
    main()

**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
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: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
MOD = 998244353

def min_expansions(intervals):
    n = len(intervals)
    dp = [[float('inf')] * (n + 1) for _ in range(1 << n)]

    # Initialize for single planet sets
    for i in range(n):
        l, r = intervals[i]
        for k in range(l, r + 1):
            dp[1 << i][k] = 0

    # Fill DP table
    for mask in range(1, 1 << n):
        for i in range(n):
            if mask & (1 << i):
                continue
            for k in range(1, n + 1):
                l, r = intervals[i]
                new_cost = min(abs(k - l), abs(k - r))
                dp[mask | (1 << i)][k] = min(dp[mask | (1 << i)][k], dp[mask][k] + new_cost)

    # Calculate total score
    total_score = 0
    for mask in range(1, 1 << n):
        min_cost = min(dp[mask])
        total_score += min_cost
        total_score %= MOD

    return total_score

# Example usage
test_cases = int(input().strip())
results = []
for _ in range(test_cases):
    n = int(input().strip())
    intervals = [tuple(map(int, input().strip().split())) for _ in range(n)]
    results.append(min_expansions(intervals))

for res in results:
    print(res)

**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
1
1 1
2
1 2
2 1
3
1 1
2 2
3 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
import java.io.*;
import java.util.*;

public class Main {
    static final int MOD = 998244353;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        StringBuilder result = new StringBuilder();

        while (t-- > 0) {
            int n = Integer.parseInt(br.readLine()); // Number of planets
            int[][] intervals = new int[n][2];

            for (int i = 0; i < n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine());
                intervals[i][0] = Integer.parseInt(st.nextToken()); // l_i
                intervals[i][1] = Integer.parseInt(st.nextToken()); // r_i
            }

            long totalScore = calculateSumScores(n, intervals);
            result.append(totalScore).append("\n");
        }

        System.out.print(result);
    }

    static long calculateSumScores(int n, int[][] intervals) {
        Arrays.sort(intervals, Comparator.comparingInt(a -> a[0]));

        long totalScore = 0;

        for (int mask = 1; mask < (1 << n); mask++) {
            int minRight = Integer.MAX_VALUE;
            int maxLeft = Integer.MIN_VALUE;
            long expansionsNeeded = 0;

            // Go through the bits of the mask to find the subset
            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) != 0) {
                    maxLeft = Math.max(maxLeft, intervals[i][0]);
                    minRight = Math.min(minRight, intervals[i][1]);
                }
            }

            if (maxLeft > minRight) {
                expansionsNeeded = maxLeft - minRight;
            }

            totalScore = (totalScore + expansionsNeeded) % MOD;
        }

        return totalScore;
    }
}

**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
3
1 1
2 2
3 3
4
1 1
2 2
3 3
4 4
5
1 1
2 2
3 3
4 4
5 5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
import java.util.Scanner;

public class UniverseDestruction {
    private static final int MOD = 998244353;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();  // Read the number of test cases

        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();  // Read the number of planets
            int[] l = new int[n];
            int[] r = new int[n];

            for (int j = 0; j < n; j++) {
                l[j] = scanner.nextInt();
                r[j] = scanner.nextInt();
            }

            long totalScore = 0;

            // To keep track of the min and max vulnerability intervals
            for (int j = 0; j < (1 << n); j++) {
                int Lmax = Integer.MIN_VALUE;
                int Rmin = Integer.MAX_VALUE;
                int count = 0;

                for (int k = 0; k < n; k++) {
                    if ((j & (1 << k)) != 0) {  // If k-th planet is included
                        Lmax = Math.max(Lmax, l[k]);
                        Rmin = Math.min(Rmin, r[k]);
                        count++;
                    }
                }

                if (count > 0) {
                    long score = Math.max(0, Lmax - Rmin);
                    totalScore = (totalScore + score) % MOD;
                }
            }

            System.out.println(totalScore);
        }

        scanner.close();
    }
}

**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
3
1 2
2 3
3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
using tup=tuple<int,int,int>;
const int N=1000005,P=998244353;
int n,l[N],r[N],fac[N],inv[N],pr[N],su[N],f[N],g[N],f2[N];
tup p[2*N];
void Inc(int&x,int y){
	if((x+=y)>=P) x-=P;
}
void Dec(int&x,int y){
	if((x-=y)<0) x+=P;
}
int bp(int x,int y){
	int r=1;
	for(;y;y=y>>1,x=1ll*x*x%P) if(y&1) r=1ll*r*x%P;
	return r;
}
int C(int x,int y){
	if(x<y) return 0;
	return 1ll*fac[x]*inv[y]%P*inv[x-y]%P;
}
void solve(){
	scanf("%d",&n),fac[0]=inv[0]=1;
	rep(i,1,n) fac[i]=1ll*fac[i-1]*i%P,inv[i]=bp(fac[i],P-2);
	f2[0]=1;
	rep(i,1,n) f2[i]=2ll*f2[i-1]%P;
	int m=0;
	rep(i,1,n) scanf("%d%d",&l[i],&r[i]),p[++m]={l[i],0,i},p[++m]={r[i],1,i};
	sort(p+1,p+m+1);
	pr[0]=f[0]=0;
	rep(i,1,m){
		pr[i]=pr[i-1],f[i]=f[i-1];
		if(get<1>(p[i])==1){
			Inc(pr[i],1);
			Inc(f[i],get<0>(p[i]));
		}
	}
	su[m+1]=g[m+1]=0;
	per(i,m,1){
		su[i]=su[i+1],g[i]=g[i+1];
		if(get<1>(p[i])==0){
			Inc(su[i],1);
			Inc(g[i],get<0>(p[i]));
		}
	}
	int as=0;
	rep(i,1,m-1){
		int c1=pr[i],c2=su[i+1],x,y,z;
		tie(x,y,z)=p[i];
		if(y==0){
			int tp=0;
			Inc(tp,1ll*g[i+1]*C(c1+c2-1,c2)%P);
			Dec(tp,1ll*f[i]*C(c1+c2-1,c1)%P);
			Inc(as,1ll*tp*f2[n-c1-c2-1]%P);
		}
		else{
			int tp=0;
			Dec(tp,1ll*x*C(c1+c2-1,c1)%P);
			if(c1>1) Dec(tp,1ll*f[i-1]*C(c1+c2-2,c1)%P);
			Inc(tp,1ll*g[i+1]*C(c1+c2-2,c1-1)%P);
			Inc(as,1ll*tp*f2[n-c1-c2]%P);
		}
	}
	printf("%d\n",as);
}
int main(){
	int T;
	scanf("%d",&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
3
3
1 1
2 2
3 3
4
1 1
2 2
3 3
4 4
5
1 1
2 2
3 3
4 4
5 5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: The Destruction of the Universe (Hard Version)
time_limit_ms: 4000
memory_limit_mb: 512
Description: This is the hard version of the problem. In this version, $n \leq 10^6$. You can only make hacks if both versions of the problem are solved.

Orangutans are powerful beings—so powerful that they only need $1$ unit of time to destroy every vulnerable planet in the universe!

There are $n$ planets in the universe. Each planet has an interval of vulnerability $[l, r]$, during which it will be exposed to destruction by orangutans. Orangutans can also expand the interval of vulnerability of any planet by $1$ unit.

Specifically, suppose the expansion is performed on planet $p$ with interval of vulnerability $[l_p, r_p]$. Then, the resulting interval of vulnerability may be either $[l_p - 1, r_p]$ or $[l_p, r_p + 1]$.

Given a set of planets, orangutans can destroy all planets if the intervals of vulnerability of all planets in the set intersect at least one common point. Let the score of such a set denote the minimum number of expansions that must be performed.

Orangutans are interested in the sum of scores of all non-empty subsets of the planets in the universe. As the answer can be large, output it modulo $998\,244\,353$.

Input: The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^6$) — the number of planets in the universe.

The following $n$ lines contain two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$) — the initial interval of vulnerability of the $i$-th planet.

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

Output: For each test case, output an integer — the sum of scores to destroy all non- empty subsets of the planets in the universe, modulo $998\,244\,353$.

Examples:
input:
3
3
1 1
2 3
3 3
4
1 4
2 3
2 4
1 1
5
1 2
2 3
3 4
4 5
1 5
output:
5
6
24

Note: In the first testcase, there are seven non-empty subsets of planets we must consider:

  * For each of the subsets $\\{[1,1]\\}, \\{[2,3]\\}, \\{[3,3]\\}$, the score is $0$.    * For the subset $\\{[2,3], [3,3]\\}$, the score is $0$, because the point $3$ is already contained in both planets' interval of vulnerability.    * For the subset $\\{[1,1], [2,3]\\}$, the score is $1$. By using one operation on changing the interval of vulnerability of the second planet to be $[1,3]$, the two planets now both have the point $1$ in their interval.    * For the subset $\\{[1,1], [3,3]\\}$, the score is $2$. By using two operations on changing the interval of vulnerability of the first planet to be $[1,3]$, the two planets now both have the point $3$ in their interval.    * For the subset $\\{[1,1], [2,3], [3,3]\\}$, the score is $2$. By using one operation on changing the interval of vulnerability of the first planet to be $[1,2]$ and one operation on changing the interval of vulnerability of the third planet to $[2,3]$, all three planets will have the point $2$ in their interval.

The sum of scores of all non-empty subsets of the first testcase is $0 \cdot 4 + 1 \cdot 1 + 2\cdot2 = 5$.

Buggy Code:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
using tup=tuple<int,int,int>;
const int N=200005,P=998244353;
int n,l[N],r[N],fac[N],inv[N],pr[N],su[N],f[N],g[N],f2[N];
tup p[2*N];
void Inc(int&x,int y){
	if((x+=y)>=P) x-=P;
}
void Dec(int&x,int y){
	if((x-=y)<0) x+=P;
}
int bp(int x,int y){
	int r=1;
	for(;y;y=y>>1,x=1ll*x*x%P) if(y&1) r=1ll*r*x%P;
	return r;
}
int C(int x,int y){
	if(x<y) return 0;
	return 1ll*fac[x]*inv[y]%P*inv[x-y]%P;
}
void solve(){
	scanf("%d",&n),fac[0]=inv[0]=1;
	rep(i,1,n) fac[i]=1ll*fac[i-1]*i%P,inv[i]=bp(fac[i],P-2);
	f2[0]=1;
	rep(i,1,n) f2[i]=2ll*f2[i-1]%P;
	int m=0;
	rep(i,1,n) scanf("%d%d",&l[i],&r[i]),p[++m]={l[i],0,i},p[++m]={r[i],1,i};
	sort(p+1,p+m+1);
	pr[0]=f[0]=0;
	rep(i,1,m){
		pr[i]=pr[i-1],f[i]=f[i-1];
		if(get<1>(p[i])==1){
			Inc(pr[i],1);
			Inc(f[i],get<0>(p[i]));
		}
	}
	su[m+1]=g[m+1]=0;
	per(i,m,1){
		su[i]=su[i+1],g[i]=g[i+1];
		if(get<1>(p[i])==0){
			Inc(su[i],1);
			Inc(g[i],get<0>(p[i]));
		}
	}
	int as=0;
	rep(i,1,m-1){
		int c1=pr[i],c2=su[i+1],x,y,z;
		tie(x,y,z)=p[i];
		if(y==0){
			int tp=0;
			Inc(tp,1ll*g[i+1]*C(c1+c2-1,c2)%P);
			Dec(tp,1ll*f[i]*C(c1+c2-1,c1)%P);
			Inc(as,1ll*tp*f2[n-c1-c2-1]%P);
		}
		else{
			int tp=0;
			Dec(tp,1ll*x*C(c1+c2-1,c1)%P);
			if(c1>1) Dec(tp,1ll*f[i-1]*C(c1+c2-2,c1)%P);
			Inc(tp,1ll*g[i+1]*C(c1+c2-2,c1-1)%P);
			Inc(as,1ll*tp*f2[n-c1-c2]%P);
		}
	}
	printf("%d\n",as);
}
int main(){
	int T;
	scanf("%d",&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
1 1
1 1
2 2
2 2
```