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 sum[800010];
int tag[800010];
void update(int root) {
  sum[root] = sum[root << 1] + sum[root << 1 | 1];
  return;
}
void pushdown(int root) {
  if (!tag[root]) return;
  tag[root << 1] = tag[root << 1 | 1] = 1;
  sum[root << 1] = sum[root << 1 | 1] = 0;
  tag[root] = 0;
  return;
}
void build(int root, int l, int r) {
  tag[root] = 0;
  if (l == r) {
    sum[root] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(root << 1, l, mid);
  build(root << 1 | 1, mid + 1, r);
  update(root);
  return;
}
void change(int root, int l, int r, int x, int y) {
  if (x <= l && r <= y) {
    tag[root] = 1;
    sum[root] = 0;
    return;
  }
  pushdown(root);
  int mid = (l + r) >> 1;
  if (x <= mid) change(root << 1, l, mid, x, y);
  if (y > mid) change(root << 1 | 1, mid + 1, r, x, y);
  update(root);
  return;
}
int query(int root, int l, int r, int x, int y) {
  if (x <= l && r <= y) return sum[root];
  pushdown(root);
  int mid = (l + r) >> 1;
  int ans = 0;
  if (x <= mid) ans += query(root << 1, l, mid, x, y);
  if (y > mid) ans += query(root << 1 | 1, mid + 1, r, x, y);
  update(root);
  return ans;
}
int n;
char s[200010];
int ansx[200010], ansy[200010];
int num;
int sta[200010];
int cnt[26];
int getmax() {
  int res = 0;
  for (int i = 0; i < 26; i++) res = max(res, cnt[i]);
  return res;
}
int getsum() {
  int res = 0;
  for (int i = 0; i < 26; i++) res += cnt[i];
  return res;
}
bool able(char a, char b) {
  cnt[a - 'a']--;
  cnt[b - 'a']--;
  bool flag = false;
  if (getmax() * 2 <= getsum()) flag = true;
  cnt[a - 'a']++;
  cnt[b - 'a']++;
  return flag;
}
void work(int l, int r) {
  num++;
  ansx[num] = query(1, 1, n, 1, l);
  ansy[num] = query(1, 1, n, 1, r);
  change(1, 1, n, l, r);
  return;
}
int pos[200010];
void solve() {
  num = 0;
  memset(cnt, 0, sizeof(cnt));
  scanf("%s", s + 1);
  n = strlen(s + 1);
  build(1, 1, n);
  for (int i = 1; i < n; i++)
    if (s[i] == s[i + 1]) cnt[s[i] - 'a']++;
  int mx = 0;
  for (char i = 1; i < 26; i++)
    if (cnt[i] > cnt[mx]) mx = i;
  int head = 0;
  if (getmax() * 2 <= getsum()) {
    for (int i = 1; i < n; i++)
      if (s[i] == s[i + 1]) {
        if (getsum() & 1) {
          cnt[s[i] - 'a']--;
          work(1, i);
        } else if (head && s[sta[head]] != s[i] && able(s[sta[head]], s[i])) {
          cnt[s[sta[head]] - 'a']--;
          cnt[s[i] - 'a']--;
          work(sta[head] + 1, i);
          head--;
        } else
          sta[++head] = i;
      }
  } else {
    for (int i = 1; i < n; i++)
      if (s[i] == s[i + 1]) {
        if (head && s[sta[head]] != s[i] &&
            (s[sta[head]] == 'a' + mx || s[i] == 'a' + mx)) {
          cnt[s[sta[head]] - 'a']--;
          cnt[s[i] - 'a']--;
          work(sta[head] + 1, i);
          head--;
        } else
          sta[++head] = i;
      }
  }
  int m = 0;
  for (int i = 1; i <= n; i++)
    if (query(1, 1, n, i, i)) pos[++m] = i;
  int lst = 0;
  for (int i = 1; i <= m; i++)
    if (s[pos[i]] == s[pos[i + 1]] || i == m) {
      work(pos[lst + 1], pos[i]);
      lst = i;
    }
  printf("%d\n", num);
  for (int i = 1; i <= num; i++) printf("%d %d\n", ansx[i], ansy[i]);
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}