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 MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = acos((long double)-1);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
int pct(int x) { return __builtin_popcount(x); }
int bit(int x) { return 31 - __builtin_clz(x); }
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
template <class A>
void re(complex<A>& c);
template <class A, class B>
void re(pair<A, B>& p);
template <class A>
void re(vector<A>& v);
template <class A, size_t SZ>
void re(array<A, SZ>& a);
template <class T>
void re(T& x) {
  cin >> x;
}
void re(double& d) {
  string t;
  re(t);
  d = stod(t);
}
void re(long double& d) {
  string t;
  re(t);
  d = stold(t);
}
template <class H, class... T>
void re(H& h, T&... t) {
  re(h);
  re(t...);
}
template <class A>
void re(complex<A>& c) {
  A a, b;
  re(a, b);
  c = {a, b};
}
template <class A, class B>
void re(pair<A, B>& p) {
  re(p.first, p.second);
}
template <class A>
void re(vector<A>& x) {
  for (auto& a : x) re(a);
}
template <class A, size_t SZ>
void re(array<A, SZ>& x) {
  for (auto& a : x) re(a);
}
template <class A, class B>
string to_string(pair<A, B> p);
template <class A>
string to_string(complex<A> c) {
  return to_string(make_pair(c.real(), c.imag()));
}
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(char c) {
  string second = "";
  second += c;
  return second;
}
string to_string(string second) { return second; }
string to_string(const char* second) { return (string)second; }
string to_string(vector<bool> v) {
  bool fst = 1;
  string res = "{";
  for (int i = (0); i < ((int)v.size()); ++i) {
    if (!fst) res += ", ";
    fst = 0;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t SZ>
string to_string(bitset<SZ> b) {
  string res = "";
  for (int i = (0); i < (SZ); ++i) res += char('0' + b[i]);
  return res;
}
template <class T>
string to_string(T v) {
  bool fst = 1;
  string res = "{";
  for (const auto& x : v) {
    if (!fst) res += ", ";
    fst = 0;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <class A>
void pr(A x) {
  cout << to_string(x);
}
template <class H, class... T>
void pr(const H& h, const T&... t) {
  pr(h);
  pr(t...);
}
void ps() { pr("\n"); }
template <class H, class... T>
void ps(const H& h, const T&... t) {
  pr(h);
  if (sizeof...(t)) pr(" ");
  ps(t...);
}
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
void setIn(string second) { freopen(second.c_str(), "r", stdin); }
void setOut(string second) { freopen(second.c_str(), "w", stdout); }
void unsyncIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
void setIO(string second = "") {
  unsyncIO();
  if ((int)second.size()) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
string second;
int cnt[26];
int getInd() {
  int sum = 0;
  for (int i = (0); i < (26); ++i) sum += cnt[i];
  for (int i = (0); i < (26); ++i)
    if (2 * cnt[i] >= sum) return i;
  return -1;
}
void solve() {
  re(second);
  for (int i = (0); i < (26); ++i) cnt[i] = 0;
  for (int i = (0); i < ((int)second.size() - 1); ++i)
    if (second[i] == second[i + 1]) cnt[second[i] - 'a']++;
  string cur;
  vector<int> ind;
  vector<pair<int, int> > sol;
  auto delLst = [&]() {
    int a = ind[(int)ind.size() - 2], b = ind.back();
    a++;
    cnt[cur[a] - 'a']--, cnt[cur[b] - 'a']--;
    42;
    sol.push_back({a + 1, b + 1});
    int num = b - a + 1;
    for (int i = (0); i < (num); ++i) cur.erase(end(cur) - 2);
    ind.pop_back(), ind.pop_back();
  };
  for (int i = (0); i < ((int)second.size()); ++i) {
    if (getInd() != -1) {
      cur += second.substr(i, (int)second.size() - i);
      break;
    }
    if ((int)cur.size() && cur.back() == second[i])
      ind.push_back((int)cur.size() - 1);
    cur += second[i];
    if ((int)ind.size() > 1 && cur[ind.back()] != cur[ind[(int)ind.size() - 2]])
      delLst();
  }
  42;
  string CUR;
  swap(cur, CUR);
  ind.clear();
  char ii = 'a' + getInd();
  42;
  for (auto& c : CUR) {
    if ((int)cur.size() && cur.back() == c) ind.push_back((int)cur.size() - 1);
    cur += c;
    if ((int)ind.size() > 1 &&
        cur[ind.back()] != cur[ind[(int)ind.size() - 2]] &&
        (cur[ind.back()] == ii || cur[ind[(int)ind.size() - 2]] == ii))
      delLst();
  }
  reverse(begin(ind), end(ind));
  for (auto& t : ind) {
    sol.push_back({t + 1, t + 1});
  }
  sol.push_back({1, (int)cur.size() - (int)ind.size()});
  ps((int)sol.size());
  for (auto& t : sol) ps(t.first, t.second);
}
int main() {
  setIO();
  int T;
  re(T);
  for (int i = (0); i < (T); ++i) solve();
}