#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 100;
long long t[4 * N], p[4 * N];
void build(long long v, long long tl, long long tr) {
  p[v] = -1;
  if (tl == tr)
    t[v] = 1;
  else {
    long long tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
void push(long long v, long long tl, long long tr) {
  if (p[v] == -1) return;
  t[v] = (tr - tl + 1) * p[v];
  if (tl != tr) p[v * 2] = p[v * 2 + 1] = p[v];
  p[v] = -1;
}
long long get(long long v, long long tl, long long tr, long long l,
              long long r) {
  push(v, tl, tr);
  if (l == tl && r == tr) return t[v];
  long long tm = (tl + tr) / 2;
  if (r <= tm) return get(v * 2, tl, tm, l, r);
  if (l >= tm + 1) return get(v * 2 + 1, tm + 1, tr, l, r);
  return get(v * 2, tl, tm, l, tm) + get(v * 2 + 1, tm + 1, tr, tm + 1, r);
}
void upd(long long v, long long tl, long long tr, long long l, long long r,
         long long val = 0) {
  if (l == tl && r == tr) {
    p[v] = val;
    push(v, tl, tr);
    return;
  }
  push(v, tl, tr);
  long long tm = (tl + tr) / 2;
  if (r <= tm)
    upd(v * 2, tl, tm, l, r, val), push(v * 2 + 1, tm + 1, tr);
  else if (l >= tm + 1)
    push(v * 2, tl, tm), upd(v * 2 + 1, tm + 1, tr, l, r, val);
  else
    upd(v * 2, tl, tm, l, tm, val), upd(v * 2 + 1, tm + 1, tr, tm + 1, r, val);
  t[v] = t[v * 2] + t[v * 2 + 1];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    string a;
    cin >> a;
    long long n = a.size();
    set<long long> s[26];
    set<pair<long long, long long> > m;
    for (long long i = 0; i < n - 1; i++)
      if (a[i] == a[i + 1]) s[a[i] - 'a'].insert(i), m.insert({i, a[i] - 'a'});
    build(1, 0, n - 1);
    vector<pair<long long, long long> > ans;
    while (true) {
      pair<long long, long long> mx(0, -1);
      for (long long i = 0; i < 26; i++) mx = max(mx, {s[i].size(), i});
      if (!mx.first) break;
      long long pos = -1;
      for (long long i = 0; i < 26; i++)
        if (i != mx.second && !s[i].empty()) pos = *s[i].begin();
      if (pos == -1) break;
      long long pos_mx;
      bool forw = true;
      {
        auto it = s[mx.second].upper_bound(pos);
        if (it == s[mx.second].end())
          it = prev(s[mx.second].lower_bound(pos)), forw = false;
        pos_mx = *it;
      }
      long long oth, pos_oth;
      {
        auto it = m.upper_bound({pos_mx, 100ll});
        if (forw) it = prev(m.lower_bound({pos_mx, 0ll}));
        pos_oth = it->first;
        oth = it->second;
      }
      long long l = pos_mx, r = pos_oth;
      if (l > r) swap(l, r);
      ans.push_back({get(1, 0, n - 1, 0, l + 1), get(1, 0, n - 1, 0, r)});
      upd(1, 0, n - 1, l + 1, r);
      s[mx.second].erase(pos_mx);
      s[oth].erase(pos_oth);
      m.erase({pos_mx, mx.second});
      m.erase({pos_oth, oth});
    }
    while (!m.empty()) {
      long long pos = m.begin()->first;
      m.erase(m.begin());
      ans.push_back({1, get(1, 0, n - 1, 0, pos)});
      upd(1, 0, n - 1, 0, pos);
    }
    ans.push_back({1, get(1, 0, n - 1, 0, n - 1)});
    cout << ans.size() << "\n";
    for (pair<long long, long long> p : ans)
      cout << p.first << " " << p.second << "\n";
  }
}

### Prompt

Please create a solution in CPP to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 100;
long long t[4 * N], p[4 * N];
void build(long long v, long long tl, long long tr) {
  p[v] = -1;
  if (tl == tr)
    t[v] = 1;
  else {
    long long tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
void push(long long v, long long tl, long long tr) {
  if (p[v] == -1) return;
  t[v] = (tr - tl + 1) * p[v];
  if (tl != tr) p[v * 2] = p[v * 2 + 1] = p[v];
  p[v] = -1;
}
long long get(long long v, long long tl, long long tr, long long l,
              long long r) {
  push(v, tl, tr);
  if (l == tl && r == tr) return t[v];
  long long tm = (tl + tr) / 2;
  if (r <= tm) return get(v * 2, tl, tm, l, r);
  if (l >= tm + 1) return get(v * 2 + 1, tm + 1, tr, l, r);
  return get(v * 2, tl, tm, l, tm) + get(v * 2 + 1, tm + 1, tr, tm + 1, r);
}
void upd(long long v, long long tl, long long tr, long long l, long long r,
         long long val = 0) {
  if (l == tl && r == tr) {
    p[v] = val;
    push(v, tl, tr);
    return;
  }
  push(v, tl, tr);
  long long tm = (tl + tr) / 2;
  if (r <= tm)
    upd(v * 2, tl, tm, l, r, val), push(v * 2 + 1, tm + 1, tr);
  else if (l >= tm + 1)
    push(v * 2, tl, tm), upd(v * 2 + 1, tm + 1, tr, l, r, val);
  else
    upd(v * 2, tl, tm, l, tm, val), upd(v * 2 + 1, tm + 1, tr, tm + 1, r, val);
  t[v] = t[v * 2] + t[v * 2 + 1];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    string a;
    cin >> a;
    long long n = a.size();
    set<long long> s[26];
    set<pair<long long, long long> > m;
    for (long long i = 0; i < n - 1; i++)
      if (a[i] == a[i + 1]) s[a[i] - 'a'].insert(i), m.insert({i, a[i] - 'a'});
    build(1, 0, n - 1);
    vector<pair<long long, long long> > ans;
    while (true) {
      pair<long long, long long> mx(0, -1);
      for (long long i = 0; i < 26; i++) mx = max(mx, {s[i].size(), i});
      if (!mx.first) break;
      long long pos = -1;
      for (long long i = 0; i < 26; i++)
        if (i != mx.second && !s[i].empty()) pos = *s[i].begin();
      if (pos == -1) break;
      long long pos_mx;
      bool forw = true;
      {
        auto it = s[mx.second].upper_bound(pos);
        if (it == s[mx.second].end())
          it = prev(s[mx.second].lower_bound(pos)), forw = false;
        pos_mx = *it;
      }
      long long oth, pos_oth;
      {
        auto it = m.upper_bound({pos_mx, 100ll});
        if (forw) it = prev(m.lower_bound({pos_mx, 0ll}));
        pos_oth = it->first;
        oth = it->second;
      }
      long long l = pos_mx, r = pos_oth;
      if (l > r) swap(l, r);
      ans.push_back({get(1, 0, n - 1, 0, l + 1), get(1, 0, n - 1, 0, r)});
      upd(1, 0, n - 1, l + 1, r);
      s[mx.second].erase(pos_mx);
      s[oth].erase(pos_oth);
      m.erase({pos_mx, mx.second});
      m.erase({pos_oth, oth});
    }
    while (!m.empty()) {
      long long pos = m.begin()->first;
      m.erase(m.begin());
      ans.push_back({1, get(1, 0, n - 1, 0, pos)});
      upd(1, 0, n - 1, 0, pos);
    }
    ans.push_back({1, get(1, 0, n - 1, 0, n - 1)});
    cout << ans.size() << "\n";
    for (pair<long long, long long> p : ans)
      cout << p.first << " " << p.second << "\n";
  }
}

```