#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s1;
    cin >> s1;
    vector<long long> arr(n);
    for (long long i = 0; i < n; i++) {
      if (s1[i] == 'a')
        arr[i] = 1;
      else if (s1[i] == 'b')
        arr[i] = -1;
    }
    map<long long, long long> m1;
    long long sum = 0;
    m1[0] = -1;
    bool ask1 = false;
    for (long long i = 0; i < n; i++) {
      sum += arr[i];
      if (m1.find(sum) != m1.end()) {
        cout << m1[sum] + 1 + 1 << " " << i + 1 << endl;
        ask1 = true;
        break;
      } else {
        m1[sum] = i;
      }
    }
    if (ask1 == false) cout << -1 << " " << -1 << endl;
  }
}
