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: import java.io.DataInputStream;
  import java.io.IOException;
  
  public class Main {
     public static void main(String[] args) throws Exception {
         initFI();
         int tc = nextInt();
         StringBuilder sb = new StringBuilder();
         while (tc-->0) {
             int n = nextInt();
             char[] arr = nextLine().toCharArray();
             int[] suma = new int[n+1];
             int[] sumb = new int[n+1];
  
             for (int i = 1; i <= n; i++) {
                 suma[i] += suma[i-1] + (arr[i-1] == 'a' ? 1 : 0);
                 sumb[i] += sumb[i-1] + (arr[i-1] == 'b' ? 1 : 0);
             }
  
             boolean chk = false;
             for (int i = 1; i < n; i++) {
                 for (int j = i+1; j <= n; j++) {
                     if (suma[j]-suma[i-1] == sumb[j]-sumb[i-1]) {
                         chk = true;
                         sb.append(i).append(' ').append(j).append('\n');
                         break;
                     }
                 }
                 if (chk) break;
             }
  
             if (chk) continue;
             sb.append(-1).append(' ').append(-1).append('\n');
         }
         System.out.println(sb);
     }
  
      private static final int DEFAULT_BUFFER_SIZE = 1 << 16;
      private static DataInputStream inputStream;
      private static byte[] buffer;
      private static int curIdx, maxIdx;
  
      private static void initFI() {
          inputStream = new DataInputStream(System.in);
          buffer = new byte[DEFAULT_BUFFER_SIZE];
          curIdx = maxIdx = 0;
      }
  
      private static String nextLine() throws IOException {
          byte[] buf = new byte[64]; // line length
          int cnt = 0, c;
          while ((c = read()) != -1) {
              if (c == '\n') {
                  if (cnt != 0) break;
                  continue;
              }
              buf[cnt++] = (byte)c;
          }
          return new String(buf, 0, cnt);
      }
  
      private static int nextInt() throws IOException {
          int ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = (c == '-');
          if (neg) c = read();
          do {
              ret = ret * 10 + c - '0';
          } while ((c = read()) >= '0' && c <= '9');
          if (neg) return -ret;
          return ret;
      }
  
      private static long nextLong() throws IOException {
          long ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = (c == '-');
          if (neg) c = read();
          do {
              ret = ret * 10 + c - '0';
          } while ((c = read()) >= '0' && c <= '9');
          if (neg) return -ret;
          return ret;
      }
  
      private static double nextDouble() throws IOException {
          double ret = 0, div = 1;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = (c == '-');
          if (neg) c = read();
          do {
              ret = ret * 10 + c - '0';
          } while ((c = read()) >= '0' && c <= '9');
          if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
          if (neg) return -ret;
          return ret;
      }
  
      private static byte read() throws IOException {
          if (curIdx == maxIdx) {
              maxIdx = inputStream.read(buffer, curIdx = 0, DEFAULT_BUFFER_SIZE);
              if (maxIdx == -1) buffer[0] = -1;
          }
          return buffer[curIdx++];
      }
  }