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;
int Times, L;
class tree {
 public:
  int sum[800010];
  void init(int p, int l, int r) {
    sum[p] = r - l + 1;
    if (l == r) return;
    int mid = (l + r) >> 1;
    init((p << 1), l, mid);
    init(((p << 1) | 1), mid + 1, r);
  }
  void modify(int p, int l, int r, int ml, int mr) {
    if (ml <= l && r <= mr) {
      sum[p] = 0;
      return;
    }
    if (!sum[p]) return;
    int mid = (l + r) >> 1;
    if (ml <= mid) modify((p << 1), l, mid, ml, mr);
    if (mr > mid) modify(((p << 1) | 1), mid + 1, r, ml, mr);
    sum[p] = sum[(p << 1)] + sum[((p << 1) | 1)];
  }
  int query(int p, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return sum[p];
    if (!sum[p]) return 0;
    int mid = (l + r) >> 1, ret = 0;
    if (ql <= mid) ret = query((p << 1), l, mid, ql, qr);
    if (qr > mid) ret += query(((p << 1) | 1), mid + 1, r, ql, qr);
    return ret;
  }
} T;
vector<pair<int, int> > opt;
void del(int l, int r) {
  int tl = T.query(1, 0, L, 0, l), tr = T.query(1, 0, L, 0, r);
  opt.push_back(make_pair(tl, tr));
  T.modify(1, 0, L, l, r);
}
void solve() {
  string s;
  cin >> s;
  int cnt[26], sum = 0;
  opt.clear();
  memset(cnt, 0, sizeof(cnt));
  L = s.size();
  T.init(1, 0, L);
  for (int i = 0; i + 1 < L; i++)
    if (s[i] == s[i + 1]) cnt[s[i] - 'a']++, sum++;
  int ans = *max_element(cnt, cnt + 26);
  printf("%d\n", max((sum + 1) / 2, ans) + 1);
  if ((sum + 1) / 2 > ans) {
    vector<int> cur;
    for (int i = 0; i + 1 < L; i++) {
      if (s[i] != s[i + 1]) continue;
      if (!cur.empty() && s[cur.back()] != s[i]) {
        del(cur.back() + 1, i);
        cnt[s[cur.back()] - 'a']--;
        cnt[s[i] - 'a']--;
        cur.pop_back();
        sum -= 2;
        ans = *max_element(cnt, cnt + 26);
        if ((sum + 1) / 2 <= ans) break;
      } else
        cur.push_back(i);
    }
  }
  vector<pair<char, int> > t;
  vector<int> cur;
  for (int i = 0; i < L; i++)
    if (T.query(1, 0, L, i, i)) t.push_back(make_pair(s[i], i));
  int main_id = max_element(cnt, cnt + 26) - cnt;
  for (int i = 0; i + 1 < t.size(); i++) {
    if (t[i].first != t[i + 1].first) continue;
    if (!cur.empty() && t[cur.back()].first != t[i].first &&
        (t[cur.back()].first - 'a' == main_id || t[i].first - 'a' == main_id)) {
      del(t[cur.back() + 1].second, t[i].second);
      cur.pop_back();
    } else
      cur.push_back(i);
  }
  vector<pair<char, int> > q;
  for (int i = 0; i < t.size(); i++)
    if (T.query(1, 0, L, t[i].second, t[i].second)) q.push_back(t[i]);
  int lst = 0;
  for (int i = 0; i + 1 < q.size(); i++) {
    if (q[i].first == q[i + 1].first) {
      del(q[lst].second, q[i].second);
      lst = i + 1;
    }
  }
  del(q[lst].second, q.back().second);
  for (auto &x : opt) printf("%d %d\n", x.first, x.second);
}
int main() {
  scanf("%d", &Times);
  while (Times--) solve();
  return 0;
}