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 maxn = 2e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
int cnt[26];
queue<int> poses[2][26];
set<int> st;
vector<pair<int, int> > ans;
string s;
int N;
struct fenwick {
  int fn[maxn];
  void reset() { fill(fn, fn + N + 5, 0); }
  void add(int pos) {
    for (pos += 3; pos < N + 5; pos += pos & -pos) fn[pos]++;
  }
  int ask(int pos) {
    int ans = 0;
    for (pos += 3; pos > 0; pos -= pos & -pos) ans += fn[pos];
    return ans;
  }
};
fenwick fn;
pair<int, int> fnd(int c) {
  while (int((poses[0][c]).size())) {
    int x = poses[0][c].front();
    auto it = st.upper_bound(x);
    if (st.count(x) && it != st.end() && s[x] != s[*it]) return {x, *it};
    poses[0][c].pop();
  }
  while (int((poses[1][c]).size())) {
    int x = poses[1][c].front();
    auto it = st.lower_bound(x);
    if (st.count(x) && it != st.begin() && s[x] != s[*prev(it)])
      return {*prev(it), x};
    poses[1][c].pop();
  }
  return {-1, -1};
}
void del(int a, int b) {
  auto it1 = st.find(a);
  auto it2 = st.find(b);
  if (it1 != st.begin() && next(it2) != st.end()) {
    int i = *prev(it1), j = *next(it2);
    if (s[i] != s[j])
      poses[0][s[i] - 'a'].push(i), poses[1][s[j] - 'a'].push(j);
  }
  cnt[s[a] - 'a']--, cnt[s[b] - 'a']--;
  ans.push_back({a, b});
  st.erase(it1), st.erase(it2);
}
void solve() {
  cin >> s;
  N = int((s).size());
  fn.reset();
  vector<pair<int, char> > vec;
  for (int i = 0; i < 26; i++) {
    cnt[i] = 0;
  }
  for (int i = 0; i < int((s).size()) - 1; i++) {
    if (s[i] == s[i + 1]) vec.push_back({i, s[i]}), cnt[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    while (int((poses[0][i]).size())) poses[0][i].pop();
    while (int((poses[1][i]).size())) poses[1][i].pop();
  }
  st.clear();
  ans.clear();
  for (int i = 0; i < int((vec).size()); i++) {
    st.insert(vec[i].first);
  }
  for (int i = 0; i < int((vec).size()) - 1; i++) {
    if (vec[i].second != vec[i + 1].second) {
      poses[0][vec[i].second - 'a'].push(vec[i].first);
      poses[1][vec[i + 1].second - 'a'].push(vec[i + 1].first);
    }
  }
  while (true) {
    int mx = 0;
    for (int i = 1; i < 26; i++) {
      if (cnt[i] > cnt[mx]) mx = i;
    }
    pair<int, int> p = fnd(mx);
    if (p.first == -1) break;
    del(p.first, p.second);
  }
  vector<pair<int, int> > ANS;
  set<int> ST;
  for (int i = 0; i < N; i++) ST.insert(i);
  for (pair<int, int> p : ans) {
    auto L = ST.upper_bound(p.first), R = ST.upper_bound(p.second);
    ANS.push_back({*L - fn.ask(*L), *prev(R) - fn.ask(*prev(R))});
    for (auto it = L; it != R; it++) fn.add(*it);
    ST.erase(L, R);
  }
  string ss;
  for (auto i : ST) ss += s[i];
  int bef = 0;
  for (int i = 1; i < int((ss).size()); i++) {
    if (ss[i] == ss[i - 1]) ANS.push_back({0, i - 1 - bef}), bef = i;
  }
  ANS.push_back({0, int((ss).size()) - 1 - bef});
  cout << int((ANS).size()) << "\n";
  for (pair<int, int> p : ANS) {
    cout << p.first + 1 << " " << p.second + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie();
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}