Problem: Dreamoon likes strings. Today he created a game about strings:

String s_1, s_2, …, s_n is beautiful if and only if for each 1 ≤ i < n, s_i ≠ s_{i+1}.

Initially, Dreamoon has a string a. In each step Dreamoon can choose a beautiful substring of a and remove it. Then he should concatenate the remaining characters (in the same order).

Dreamoon wants to use the smallest number of steps to make a empty. Please help Dreamoon, and print any sequence of the smallest number of steps to make a empty.

Input

The first line contains an integer t (1 ≤ t ≤ 200 000), denoting the number of test cases in the input.

For each test case, there's one line with a non-empty string of lowercase Latin letters a.

The total sum of lengths of strings in all test cases is at most 200 000.

Output

For each test case, in the first line, you should print m: the smallest number of steps to make a empty. Each of the following m lines should contain two integers l_i, r_i (1 ≤ l_i ≤ r_i ≤ |a|), denoting, that the i-th step is removing the characters from index l_i to r_i in the current string. (indices are numbered starting from 1). 

Note that after the deletion of the substring, indices of remaining characters may change, and r_i should be at most the current length of a.

If there are several possible solutions, you can print any.

Example

Input


4
aabbcc
aaabbb
aaa
abacad


Output


3
3 3
2 4
1 2
3
3 4
2 3
1 2
3
1 1
1 1
1 1
1
1 6

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int c = 200002;
int w, n, db[32], dp[c], cnt, maxi, pos;
bool tor[c];
string s;
vector<pair<int, int> > sz, h;
vector<int> ss;
int ask(int a) {
  int sum = 0;
  while (a) sum += dp[a], a -= ((a) & -(a));
  return sum;
}
void pl(int a, int b) {
  while (a <= n) dp[a] += b, a += ((a) & -(a));
}
void add(int a, int b) {
  int x = a - ask(a), y = b - ask(b);
  cout << x << " " << y << "\n";
  pl(a, y - x + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> w;
  for (int i = 1; i <= w; i++) {
    cin >> s;
    n = s.size();
    pos = 0, maxi = 0, cnt = 0, sz.clear(), h.clear(), ss.clear();
    for (int i = 0; i < 30; i++) db[i] = 0;
    for (int i = 0; i <= n; i++) tor[i] = 0, dp[i] = 0;
    for (int i = 0; i < n - 1; i++)
      if (s[i] == s[i + 1]) {
        int x = s[i] - 'a' + 1;
        if (s[i] == s[i + 1]) {
          db[x]++, cnt++;
          if (db[x] > db[pos]) pos = x;
          sz.push_back({x, i + 1});
        }
      }
    maxi = db[pos];
    cout << max(maxi, (cnt + 1) / 2) + 1 << "\n";
    for (int i = 0; i < sz.size(); i++) {
      int x = sz[i].first, p2 = sz[i].second;
      if (ss.size() > 0) {
        int id = ss.back(), y = sz[id].first, p1 = sz[id].second;
        if (x != y && 2 * maxi < cnt) {
          tor[id] = 1, tor[i] = 1, db[x]--, db[y]--, cnt -= 2, ss.pop_back();
          add(p1 + 1, p2);
        }
        for (int i = 0; i < 30; i++)
          if (db[i] > db[pos]) pos = i;
        maxi = db[pos];
      }
      if (!tor[i]) ss.push_back(i);
    }
    for (int i = 0; i < sz.size(); i++) {
      if (!tor[i]) {
        int x = sz[i].first, p2 = sz[i].second, jo = 0;
        if (h.size() > 0) {
          int y = h.back().first, p1 = h.back().second;
          if (x != y && (x == pos || y == pos))
            jo = 1, add(p1 + 1, p2), h.pop_back();
        }
        if (!jo) h.push_back({x, p2});
      }
    }
    for (int i = 0; i < h.size(); i++) add(h[i].second + 1, h[i].second + 1);
    add(1, n);
  }
  return 0;
}