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;
using ll = long long;
mt19937 mt(736);
int get_ans(const array<int, 26> &cnt) {
  return max(*max_element(cnt.begin(), cnt.end()),
             accumulate(cnt.begin(), cnt.end(), 1) / 2);
}
vector<pair<int, int>> foo(string str) {
  array<int, 26> cnt{};
  for (auto &it : str) cnt[it - 'a']++;
  vector<pair<int, int>> ans;
  ans.reserve(get_ans(cnt));
  array<array<vector<pair<int, int>>, 26>, 26> prs;
  set<int> alive;
  for (int i = 0; i < str.size(); i++) alive.insert(i);
  for (int i = 1; i < str.size(); i++)
    if (str[i - 1] != str[i]) {
      prs[str[i - 1] - 'a'][str[i] - 'a'].emplace_back(i - 1, i);
      prs[str[i] - 'a'][str[i - 1] - 'a'].emplace_back(i - 1, i);
    }
  int ga;
  while ((ga = get_ans(cnt)) < alive.size()) {
    auto q = max_element(cnt.begin(), cnt.end()) - cnt.begin();
    for (auto &it : prs[q]) {
      while (!it.empty() &&
             (str[it.back().first] == ' ' || str[it.back().second] == ' '))
        it.pop_back();
      if (!it.empty()) {
        cnt[str[it.back().first] - 'a']--;
        cnt[str[it.back().second] - 'a']--;
        if (get_ans(cnt) + 1 == ga) {
          alive.erase(it.back().first);
          alive.erase(it.back().second);
          str[it.back().first] = ' ';
          str[it.back().second] = ' ';
          ans.push_back(it.back());
          ans.back().second++;
          auto wh = alive.lower_bound(it.back().first);
          if (wh != alive.begin() && wh != alive.end()) {
            auto le = wh, ri = wh;
            --le;
            if (str[*le] != str[*ri]) {
              prs[str[*le] - 'a'][str[*ri] - 'a'].emplace_back(*le, *ri);
              prs[str[*ri] - 'a'][str[*le] - 'a'].emplace_back(*le, *ri);
            }
          }
          break;
        } else {
          cnt[str[it.back().first] - 'a']++;
          cnt[str[it.back().second] - 'a']++;
        }
      }
    }
  }
  for (int i = 0; i < str.size(); i++)
    if (str[i] != ' ') {
      alive.erase(i);
      ans.emplace_back(i, i + 1);
    }
  assert(alive.empty());
  return ans;
}
int up(int n) {
  int r = 1;
  while (r < n) r *= 2;
  return r;
}
class segtree {
  vector<int> arr;
  [[nodiscard]] int sum(int l, int r, int cl, int cr, int v) const {
    if (r <= cl || cr <= l) return 0;
    if (l <= cl && cr <= r) return arr[v];
    int ct = (cl + cr) / 2;
    return sum(l, r, cl, ct, 2 * v) + sum(l, r, ct, cr, 2 * v + 1);
  }

 public:
  segtree(int n) : arr(2 * up(n)) {}
  void add(int wh, int x) {
    for (wh += arr.size() / 2; wh > 0; wh /= 2) arr[wh] += x;
  }
  [[nodiscard]] int sum(int l, int r) const {
    return sum(l, r, 0, arr.size() / 2, 1);
  }
  [[nodiscard]] int sum(int l = 0) const {
    return sum(l, arr.size() / 2, 0, arr.size() / 2, 1);
  }
};
void solve_test(istream &cin = std::cin, ostream &cout = std::cout) {
  string str;
  cin >> str;
  string nw;
  vector<int> pos;
  for (int i = 1; i < str.size(); i++)
    if (str[i - 1] == str[i]) {
      pos.emplace_back(i);
      nw += str[i];
    }
  auto ans = foo(nw);
  segtree st(str.size());
  for (int i = 0; i < str.size(); i++) st.add(i, 1);
  cout << ans.size() + 1 << '\n';
  set<int> alive;
  for (int i = 0; i < str.size(); i++) alive.insert(i);
  for (auto it : ans) {
    int l = pos[it.first], r = pos[it.second - 1];
    if (l == r) l--;
    cout << st.sum(0, l) + 1 << ' ' << st.sum(0, r) << '\n';
    while (true) {
      auto wh = alive.lower_bound(l);
      if (wh == alive.end() || *wh >= r) break;
      st.add(*wh, -1);
      alive.erase(wh);
    }
  }
  cout << 1 << ' ' << st.sum() << '\n';
}
void solve(istream &cin = std::cin, ostream &cout = std::cout) {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve_test(cin, cout);
  }
}
void gen(ostream &cout = std::cout) {
  const int t = 1;
  cout << t << endl;
  cout << string(int(1e5), 'z') << string(int(1e5), 'y') << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  solve();
  return 0;
}