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 N = 2e5 + 5;
int T, n, i;
char c[N];
struct node {
  int pre, nxt, be, en;
} a[N];
int xb;
int bi[N];
inline void add(int x, int v) {
  for (; x <= n; x += x & -x) bi[x] += v;
}
inline int ask(int x) {
  int ans = 0;
  for (; x; x -= x & -x) ans += bi[x];
  return ans;
}
int main() {
  for (scanf("%d", &T); T--;) {
    scanf("%s", c + 1);
    n = strlen(c + 1);
    for (i = 1; i <= n; ++i) bi[i] = i & -i;
    for (i = 1, xb = 0; i <= n; ++i) {
      if (xb && c[a[xb].en] != c[i])
        a[xb].en = i;
      else
        a[++xb] = (node){xb - 1, 0, i, i}, a[xb - 1].nxt = xb;
    }
    a[0].nxt = 1;
    a[xb].nxt = xb + 1;
    a[xb + 1].pre = xb;
    static int buc[26];
    queue<int> q[26];
    memset(buc, 0, 104);
    static bool del[N];
    memset(del + 1, 0, xb);
    auto ck = [&](int i) {
      return !del[i] && 0 < a[i].pre && a[i].nxt < xb + 1 &&
             c[a[i].be] != c[a[i].en];
    };
    auto tryins = [&](int i) {
      if (ck(i)) q[c[a[i].be] - 'a'].push(i), q[c[a[i].en] - 'a'].push(i);
    };
    for (i = 1; i < xb; ++i) ++buc[c[a[i].en] - 'a'];
    for (i = 2; i < xb; ++i) tryins(i);
    vector<pair<int, int>> ans;
    set<int> S;
    for (i = 1; i <= n; ++i) S.insert(i);
    auto pushh = [&](int i) {
      ans.push_back({ask(a[i].be), ask(a[i].en)});
      if (a[i].be > 1) --buc[c[a[i].be] - 'a'];
      if (a[i].en < n) --buc[c[a[i].en] - 'a'];
      for (auto it = S.lower_bound(a[i].be); it != S.end() && *it <= a[i].en;
           S.erase(it++))
        add(*it, -1);
    };
    for (;;) {
      int mx = -1, mxid;
      for (i = 0; i < 26; ++i)
        if (buc[i] > mx) mx = buc[i], mxid = i;
      auto ck2 = [&](int i, char cc) {
        return c[a[i].be] == cc || c[a[i].en] == cc;
      };
      i = mxid;
      for (;
           !q[i].empty() && (!ck2(q[i].front(), i + 'a') || !ck(q[i].front()));
           q[i].pop())
        ;
      if (q[i].empty()) break;
      i = q[i].front();
      pushh(i);
      int x = a[i].pre, y = a[i].nxt;
      del[i] = del[y] = 1;
      a[x].en = a[y].en;
      y = a[y].nxt;
      a[x].nxt = y;
      a[y].pre = x;
      tryins(x);
    }
    for (i = a[0].nxt; i <= xb; i = a[i].nxt) pushh(i);
    printf("%d\n", (int)ans.size());
    for (auto u : ans) printf("%d %d\n", u.first, u.second);
  }
}