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>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
set<pair<int, int> > se[26][26];
set<int> idx;
int alpha[26];
int N;
char S[200011];
vector<pair<int, int> > ps, ans;
int stk[200011];
vector<int> G[200011];
void dfs(int v, int h) {
  int len = 0;
  for (__typeof((G[v]).begin()) e = (G[v]).begin(), e_end = (G[v]).end();
       e != e_end; ++e) {
    dfs(*e, h + len);
    len += ps[*e].second - ps[*e].first;
  }
  ans.emplace_back(ps[v].first - h, ps[v].second - h - len);
}
void MAIN() {
  for (int a = 0, a_len = (26); a < a_len; ++a)
    for (int b = 0, b_len = (26); b < b_len; ++b) se[a][b].clear();
  idx.clear();
  memset(alpha, 0, sizeof alpha);
  scanf("%s", S);
  N = strlen(S);
  for (int i = 0, i_len = (N); i < i_len; ++i) G[i].clear();
  vector<int> idxv;
  for (int i = 0, i_len = (N - 1); i < i_len; ++i)
    if (S[i] == S[i + 1]) {
      idx.insert(i + 1);
      idxv.push_back(i + 1);
      alpha[S[i] - 'a']++;
    }
  for (int i = 0, i_len = ((int)idxv.size() - 1); i < i_len; ++i) {
    int a = S[idxv[i]] - 'a';
    int b = S[idxv[i + 1]] - 'a';
    se[a][b].emplace(idxv[i], idxv[i + 1]);
  }
  idxv.clear();
  ps.clear();
  while (1) {
    int a = 0;
    for (int c = 0, c_len = (26); c < c_len; ++c)
      if (alpha[a] < alpha[c]) a = c;
    if (alpha[a] == 0) break;
    int b = -1;
    for (int c = 0, c_len = (26); c < c_len; ++c)
      if (c != a) {
        if (se[a][c].size()) {
          b = c;
          break;
        }
        if (se[c][a].size()) {
          b = a;
          a = c;
          break;
        }
      }
    if (b == -1) break;
    auto p = *se[a][b].begin();
    se[a][b].erase(se[a][b].begin());
    alpha[a]--;
    alpha[b]--;
    ps.push_back(p);
    idx.erase(p.first);
    idx.erase(p.second);
    auto it = idx.lower_bound(p.second);
    if (it != idx.end()) {
      int c = S[*it] - 'a';
      se[b][c].erase(make_pair(p.second, *it));
    }
    if (it != idx.begin()) {
      auto left = prev(it);
      int x = S[*left] - 'a';
      se[x][a].erase(make_pair(*left, p.first));
      if (it != idx.end()) {
        int c = S[*it] - 'a';
        se[x][c].emplace(*left, *it);
      }
    }
  }
  for (__typeof((idx).begin()) e = (idx).begin(), e_end = (idx).end();
       e != e_end; ++e)
    ps.emplace_back(0, *e);
  ps.emplace_back(0, N);
  printf("%d\n", (int)ps.size());
  sort(ps.begin(), ps.end(),
       [](const pair<int, int> &x, const pair<int, int> &y) {
         return x.first != y.first ? x.first < y.first : x.second > y.second;
       });
  stk[0] = 0;
  int t = 0;
  for (int i = 1; i < (int)ps.size(); i++) {
    while (ps[stk[t]].second <= ps[i].first) {
      t--;
    }
    G[stk[t]].push_back(i);
    stk[++t] = i;
  }
  ans.clear();
  dfs(0, 0);
  for (__typeof((ans).begin()) e = (ans).begin(), e_end = (ans).end();
       e != e_end; ++e) {
    printf("%d %d\n", e->first + 1, e->second);
  }
}
int main() {
  int TC = 1;
  scanf("%d", &TC);
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}