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>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
using namespace std;
int n;
int tre[201000];
inline void add(int i, int x) {
  while (i <= n) tre[i] += x, i += ((i) & (-(i)));
}
inline int query(int i) {
  int res = 0;
  while (i) res += tre[i], i -= ((i) & (-(i)));
  return res;
}
pair<int, int> ans[201000];
int atot;
inline void Push(int l, int r) {
  int L = query(l), R = query(r);
  if (L >= R) {
    printf("QAQ : Push(%d, %d), L = %d, R = %d\n", l, r, L, R);
    exit(-1);
  }
  ans[++atot] = make_pair(L + 1, R);
  add(r, -(R - L));
}
inline void Print() {
  printf("%d\n", atot);
  for (int i = 1; i <= atot; ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
}
char s[201000];
int pos[201000], ptot;
int pre[201000], nxt[201000];
int cnt[27];
priority_queue<pair<int, int> > q;
set<int> st[27];
inline int Col(int p) { return s[pos[p]] - 'a'; }
inline void Link(int p) {
  int q = pre[p];
  if (!p || !q) return;
  if (Col(p) != Col(q)) {
    st[Col(q)].insert(p);
    st[Col(p)].insert(p);
  }
}
inline void Cancl(int p) {
  if (!p || !pre[p] || Col(p) == Col(pre[p])) return;
  st[Col(p)].erase(p);
  st[Col(pre[p])].erase(p);
}
inline void Cut(int p) {
  int q = pre[p];
  int pe = pre[q], nt = nxt[p];
  --cnt[Col(p)];
  if (cnt[Col(p)]) ::q.push(make_pair(cnt[Col(p)], Col(p)));
  --cnt[Col(q)];
  if (cnt[Col(q)]) ::q.push(make_pair(cnt[Col(q)], Col(q)));
  Cancl(q);
  Cancl(p);
  Cancl(nt);
  Push(pos[q], pos[p]);
  pre[nt] = pe;
  nxt[pe] = nt;
  if (nt <= ptot) Link(nt);
}
inline void calc() {
  for (int i = 2; i <= ptot; ++i) {
    pre[i] = i - 1, nxt[i - 1] = i;
    Link(i);
  }
  pre[1] = 0;
  nxt[ptot] = ptot + 1;
  nxt[0] = 1;
  pre[ptot + 1] = ptot;
  for (int i = 1; i <= ptot; ++i) ++cnt[s[pos[i]] - 'a'];
  for (int c = 0; c < 26; ++c)
    if (cnt[c]) q.push(make_pair(cnt[c], c));
  while (q.size()) {
    pair<int, int> pr = q.top();
    q.pop();
    int c = pr.second;
    if (cnt[c] != pr.first) continue;
    if (!st[c].size()) {
      for (int p = nxt[0]; p <= ptot; p = nxt[p]) {
        Push(0, pos[p]);
      }
      break;
    }
    int p = *st[c].begin();
    Cut(p);
  }
  Push(0, n);
}
inline void work() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i < n; ++i)
    if (s[i] == s[i + 1]) pos[++ptot] = i;
  for (int i = 1; i <= n; ++i) add(i, 1);
  calc();
  Print();
}
inline void clear() {
  atot = 0;
  memset(tre, 0, (n + 3) << 2);
  memset(pos, 0, (ptot + 3) << 2);
  memset(pre, 0, (ptot + 3) << 2);
  memset(nxt, 0, (ptot + 3) << 2);
  memset(cnt, 0, sizeof(cnt));
  while (q.size()) q.pop();
  for (int c = 0; c < 26; ++c) st[c].clear();
  ptot = 0;
}
int main() {
  int _;
  read(_);
  while (_--) work(), clear();
  return 0;
}