description: You are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n.
  
  s[l; r] is a continuous substring of letters from index l to r of the string inclusive. 
  
  A string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings "baba" and "aabbab" are balanced and strings "aaab" and "b" are not.
  
  Find any non-empty balanced substring s[l; r] of string s. Print its l and r (1 ≤ l ≤ r ≤ n). If there is no such substring, then print -1 -1.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.
  
  Then the descriptions of t testcases follow.
  
  The first line of the testcase contains a single integer n (1 ≤ n ≤ 50) — the length of the string.
  
  The second line of the testcase contains a string s, consisting of n letters, each letter is either 'a' or 'b'.
  
  Output
  
  For each testcase print two integers. If there exists a non-empty balanced substring s[l; r], then print l r (1 ≤ l ≤ r ≤ n). Otherwise, print -1 -1.
  
  Example
  
  Input
  
  
  4
  1
  a
  6
  abbaba
  6
  abbaba
  9
  babbabbaa
  
  
  Output
  
  
  -1 -1
  1 6
  3 6
  2 5
  
  Note
  
  In the first testcase there are no non-empty balanced subtrings.
  
  In the second and third testcases there are multiple balanced substrings, including the entire string "abbaba" and substring "baba".
solution: /* package codechef; // don't place package name! */
  import java.io.*;
  import java.lang.*;
  import java.util.*;
  import java.util.Collection;
  import static java.lang.Math.*;  
  public class Main implements Runnable 
  {  
       static int gcd(int a, int b)
      {
        if (b == 0)
          return a;
        return gcd(b, a % b);
      }
      public void run() 
      {
          InputReader s = new InputReader(System.in);
          PrintWriter out = new PrintWriter(System.out);
          int t = s.nextInt();
          while(t-- > 0)
          {
              int n = s.nextInt();
            String str = s.next();
            int i,j;
            int l = -1, m = -1;
            boolean b = false;
            int count = 0;
            for(i=0;i<n-1;i++)
            {
              if(b == true)
              {
                  break;
              }
              count = 0;
              for(j=i;j<n;j++)
              {
                 if(str.charAt(j) == 'a')
                 {
                   count++;
                 }
                 else
                 {
                  count--;
                 }
                 if(count == 0)
                 {
                   b = true;
                   l = i+1;
                   m = j+1;
                   break;
                 }
              }
            }
            if(b == false)
            {
              out.println("-1 -1");
            }
            else
            {
              out.println(l + " " + m);
            }
          }
           out.close();
        }
      static class InputReader {
          private InputStream stream;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;;
          private SpaceCharFilter filter;
          private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   
          public InputReader(InputStream stream) {
              this.stream = stream;
          }
          
          public int read() {
              if (numChars==-1) 
                  throw new InputMismatchException();
              
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  }
                  catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  
                  if(numChars <= 0)               
                      return -1;
              }
              return buf[curChar++];
          }
       
          public String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              }
              catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
          public int nextInt() {
              int c = read();
              
              while(isSpaceChar(c)) 
                  c = read();
              
              int sgn = 1;
              
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              
              int res = 0;
              do {
                  if(c<'0'||c>'9') 
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              while (!isSpaceChar(c)); 
              
              return res * sgn;
          }
          
          public long nextLong() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
              
              do {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              while (!isSpaceChar(c));
                  return res * sgn;
          }
          
          public double nextDouble() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              double res = 0;
              while (!isSpaceChar(c) && c != '.') {
                  if (c == 'e' || c == 'E')
                      return res * Math.pow(10, nextInt());
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              if (c == '.') {
                  c = read();
                  double m = 1;
                  while (!isSpaceChar(c)) {
                      if (c == 'e' || c == 'E')
                          return res * Math.pow(10, nextInt());
                      if (c < '0' || c > '9')
                          throw new InputMismatchException();
                      m /= 10;
                      res += (c - '0') * m;
                      c = read();
                  }
              }
              return res * sgn;
          }
          
          public String readString() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              StringBuilder res = new StringBuilder();
              do {
                  res.appendCodePoint(c);
                  c = read();
              } 
              while (!isSpaceChar(c));
              
              return res.toString();
          }
       
          public boolean isSpaceChar(int c) {
              if (filter != null)
                  return filter.isSpaceChar(c);
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
          
       
          public String next() {
              return readString();
          }
          
          public interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
          }
      }
      public static void main(String args[]) throws Exception {
          new Thread(null, new Main(),"Main",1<<26).start();
      }
  }
  
   
  
          
   
  