#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x7fffffffffffffff;
const double eps = 1e-10;
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a >= 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) {
  return a < b ? b : a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) {
  return a < b ? a : b;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (b < a) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) bool _cmp(const _Tp &a,
                                                    const _Tp &b) {
  return abs(a - b) <= eps;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  register char ch(getchar());
  bool f(false);
  while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (ch >= 48 && ch <= 57)
    x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  if (f) x = -x;
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  register char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  register char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 200005;
char s[N], t[N];
int cnt[26];
int st[N], top;
int calc() {
  int maxx = 0;
  for (int i = 0; i < 26; ++i) chmax(maxx, cnt[i]);
  return maxx;
}
struct BIT {
  int c[N], n;
  __inline__ __attribute__((always_inline)) void add(int x, int C) {
    for (; x <= n; x += ((x) & (-x))) c[x] += C;
  }
  __inline__ __attribute__((always_inline)) int sum(int x) {
    int ans = 0;
    for (; x; x -= ((x) & (-x))) ans += c[x];
    return ans;
  }
} tr;
int id[N];
int sum[N];
void MAIN() {
  memset(cnt, 0, sizeof(cnt));
  top = 0;
  int n = read_str(s + 1);
  memset(sum, 0, (n + 3) << 2);
  tr.n = n;
  memset(tr.c, 0, (n + 3) << 2);
  int m = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] == s[i + 1]) {
      t[++m] = s[i];
      ++cnt[t[m] - 97];
      id[m] = i;
    }
  }
  int maxx = 0, pos = 0;
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] > maxx) {
      maxx = cnt[i];
      pos = i;
    }
  }
  std::vector<std::pair<int, int> > ans;
  if (maxx * 2 >= m) {
    char ch = pos + 97;
    for (int i = 1; i <= m; ++i) {
      if (t[i] == ch) {
        if (!top)
          st[++top] = i;
        else {
          if (t[st[top]] == ch)
            st[++top] = i;
          else {
            ans.push_back(std::make_pair(id[st[top]] + 1, id[i]));
            --top;
          }
        }
      } else {
        if (!top)
          st[++top] = i;
        else {
          if (t[st[top]] != ch)
            st[++top] = i;
          else {
            ans.push_back(std::make_pair(id[st[top]] + 1, id[i]));
            --top;
          }
        }
      }
    }
  } else {
    if (m & 1) {
      --cnt[t[m] - 97];
      --m;
    }
    int rest = m;
    for (int i = 1; i <= m; ++i) {
      if (!top || t[st[top]] == t[i])
        st[++top] = i;
      else {
        --cnt[t[i] - 97];
        --cnt[t[st[top]] - 97];
        rest -= 2;
        if (calc() * 2 <= rest) {
          ans.push_back(std::make_pair(id[st[top]] + 1, id[i]));
          --top;
        } else {
          rest += 2;
          ++cnt[t[i] - 97];
          ++cnt[t[st[top]] - 97];
          st[++top] = i;
        }
      }
    }
  }
  for (auto &&it : ans) {
    int l = it.first;
    int r = it.second;
    ++sum[l], --sum[r + 1];
    l -= tr.sum(l);
    r -= tr.sum(r);
    tr.add(it.second, r - l + 1);
    it = std::make_pair(l, r);
  }
  for (int i = 1; i <= n; ++i) {
    sum[i] += sum[i - 1];
  }
  m = 0;
  for (int i = 1; i <= n; ++i) {
    if (!sum[i]) {
      t[++m] = s[i];
    }
  }
  int last = 1;
  int qwq = 0;
  for (int i = 1; i < m; ++i) {
    if (t[i] == t[i + 1]) {
      ans.push_back(std::make_pair(last - qwq, i - qwq));
      qwq += i - last + 1;
      last = i + 1;
    }
  }
  ans.push_back(std::make_pair(last - qwq, m - qwq));
  printf("%d\n", (int)ans.size());
  for (auto it : ans) {
    printf("%d %d\n", it.first, it.second);
  }
}
int main() {
  int _;
  read(_);
  while (_--) MAIN();
  return 0;
}

### Prompt

Please formulate a CPP solution 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>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x7fffffffffffffff;
const double eps = 1e-10;
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a >= 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) {
  return a < b ? b : a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) {
  return a < b ? a : b;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (b < a) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) bool _cmp(const _Tp &a,
                                                    const _Tp &b) {
  return abs(a - b) <= eps;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  register char ch(getchar());
  bool f(false);
  while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (ch >= 48 && ch <= 57)
    x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  if (f) x = -x;
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  register char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  register char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 200005;
char s[N], t[N];
int cnt[26];
int st[N], top;
int calc() {
  int maxx = 0;
  for (int i = 0; i < 26; ++i) chmax(maxx, cnt[i]);
  return maxx;
}
struct BIT {
  int c[N], n;
  __inline__ __attribute__((always_inline)) void add(int x, int C) {
    for (; x <= n; x += ((x) & (-x))) c[x] += C;
  }
  __inline__ __attribute__((always_inline)) int sum(int x) {
    int ans = 0;
    for (; x; x -= ((x) & (-x))) ans += c[x];
    return ans;
  }
} tr;
int id[N];
int sum[N];
void MAIN() {
  memset(cnt, 0, sizeof(cnt));
  top = 0;
  int n = read_str(s + 1);
  memset(sum, 0, (n + 3) << 2);
  tr.n = n;
  memset(tr.c, 0, (n + 3) << 2);
  int m = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] == s[i + 1]) {
      t[++m] = s[i];
      ++cnt[t[m] - 97];
      id[m] = i;
    }
  }
  int maxx = 0, pos = 0;
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] > maxx) {
      maxx = cnt[i];
      pos = i;
    }
  }
  std::vector<std::pair<int, int> > ans;
  if (maxx * 2 >= m) {
    char ch = pos + 97;
    for (int i = 1; i <= m; ++i) {
      if (t[i] == ch) {
        if (!top)
          st[++top] = i;
        else {
          if (t[st[top]] == ch)
            st[++top] = i;
          else {
            ans.push_back(std::make_pair(id[st[top]] + 1, id[i]));
            --top;
          }
        }
      } else {
        if (!top)
          st[++top] = i;
        else {
          if (t[st[top]] != ch)
            st[++top] = i;
          else {
            ans.push_back(std::make_pair(id[st[top]] + 1, id[i]));
            --top;
          }
        }
      }
    }
  } else {
    if (m & 1) {
      --cnt[t[m] - 97];
      --m;
    }
    int rest = m;
    for (int i = 1; i <= m; ++i) {
      if (!top || t[st[top]] == t[i])
        st[++top] = i;
      else {
        --cnt[t[i] - 97];
        --cnt[t[st[top]] - 97];
        rest -= 2;
        if (calc() * 2 <= rest) {
          ans.push_back(std::make_pair(id[st[top]] + 1, id[i]));
          --top;
        } else {
          rest += 2;
          ++cnt[t[i] - 97];
          ++cnt[t[st[top]] - 97];
          st[++top] = i;
        }
      }
    }
  }
  for (auto &&it : ans) {
    int l = it.first;
    int r = it.second;
    ++sum[l], --sum[r + 1];
    l -= tr.sum(l);
    r -= tr.sum(r);
    tr.add(it.second, r - l + 1);
    it = std::make_pair(l, r);
  }
  for (int i = 1; i <= n; ++i) {
    sum[i] += sum[i - 1];
  }
  m = 0;
  for (int i = 1; i <= n; ++i) {
    if (!sum[i]) {
      t[++m] = s[i];
    }
  }
  int last = 1;
  int qwq = 0;
  for (int i = 1; i < m; ++i) {
    if (t[i] == t[i + 1]) {
      ans.push_back(std::make_pair(last - qwq, i - qwq));
      qwq += i - last + 1;
      last = i + 1;
    }
  }
  ans.push_back(std::make_pair(last - qwq, m - qwq));
  printf("%d\n", (int)ans.size());
  for (auto it : ans) {
    printf("%d %d\n", it.first, it.second);
  }
}
int main() {
  int _;
  read(_);
  while (_--) MAIN();
  return 0;
}

```