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.*;
  import java.util.*;
  
  public class BalancedSubstring implements Runnable {
  
     void solve() {
        int t = ri();
        outer: while (t-- > 0) {
           Map<Integer, Integer> map = new HashMap<>();
           map.put(0, -1);
           int len = ri();
           String s = rs();
           int count = 0;// Increment for a and decrement for b
           for (int i = 0; i < s.length(); i++) {
              if (s.charAt(i) == 'a')
                 count++;
              else
                 count--;
              if (map.containsKey(count)) {
                 int start = map.get(count);
                 println((start + 2) + " " + (i + 1));
                 continue outer;
              }
              map.put(count, i);
           }
           println(-1 + " -" + 1);
        }
     }
  
     /************************************************************************************************************************************************/
     public static void main(String[] args) throws IOException {
        new Thread(null, new BalancedSubstring(), "1").start();
     }
  
     static PrintWriter out = new PrintWriter(System.out);
     static Reader read = new Reader();
     static StringBuilder sbr = new StringBuilder();
     static int mod = (int) 1e9 + 7;
     static int dmax = Integer.MAX_VALUE;
     static long lmax = Long.MAX_VALUE;
     static int dmin = Integer.MIN_VALUE;
     static long lmin = Long.MIN_VALUE;
     static int[] dprimes = new int[] { 1, 11, 101, 1087, 99991, 100001, 1000003, 15485863, 999999937 };
  
     @Override
     public void run() {
        solve();
        out.close();
     }
  
     static class Reader {
        private byte[] buf = new byte[1024];
        private int index;
        private InputStream in;
        private int total;
  
        public Reader() {
           in = System.in;
        }
  
        public int scan() throws IOException {
           if (total < 0)
              throw new InputMismatchException();
           if (index >= total) {
              index = 0;
              total = in.read(buf);
              if (total <= 0)
                 return -1;
           }
           return buf[index++];
        }
  
        public int intNext() throws IOException {
           int integer = 0;
           int n = scan();
           while (isWhiteSpace(n))
              n = scan();
           int neg = 1;
           if (n == '-') {
              neg = -1;
              n = scan();
           }
           while (!isWhiteSpace(n)) {
              if (n >= '0' && n <= '9') {
                 integer *= 10;
                 integer += n - '0';
                 n = scan();
              } else
                 throw new InputMismatchException();
           }
           return neg * integer;
        }
  
        public double doubleNext() throws IOException {
           double doub = 0;
           int n = scan();
           while (isWhiteSpace(n))
              n = scan();
           int neg = 1;
           if (n == '-') {
              neg = -1;
              n = scan();
           }
           while (!isWhiteSpace(n) && n != '.') {
              if (n >= '0' && n <= '9') {
                 doub *= 10;
                 doub += n - '0';
                 n = scan();
              } else
                 throw new InputMismatchException();
           }
           if (n == '.') {
              n = scan();
              double temp = 1;
              while (!isWhiteSpace(n)) {
                 if (n >= '0' && n <= '9') {
                    temp /= 10;
                    doub += (n - '0') * temp;
                    n = scan();
                 } else
                    throw new InputMismatchException();
              }
           }
           return doub * neg;
        }
  
        public String read() throws IOException {
           StringBuilder sb = new StringBuilder();
           int n = scan();
           while (isWhiteSpace(n))
              n = scan();
           while (!isWhiteSpace(n)) {
              sb.append((char) n);
              n = scan();
           }
           return sb.toString();
        }
  
        public String rline() throws IOException {
           StringBuilder sb = new StringBuilder();
           int n = scan();
           while (n != '\n') {
              sb.append((char) n);
              n = scan();
           }
           return sb.toString();
        }
  
        private boolean isWhiteSpace(int n) {
           if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
              return true;
           return false;
        }
     }
  
     static void print(Object object) {
        out.print(object);
     }
  
     static void println(Object object) {
        out.println(object);
     }
  
     static int[] iArr(int len) {
        return new int[len];
     }
  
     static long[] lArr(int len) {
        return new long[len];
     }
  
     static long min(long a, long b) {
        return Math.min(a, b);
     }
  
     static int min(int a, int b) {
        return Math.min(a, b);
     }
  
     static long max(Long a, Long b) {
        return Math.max(a, b);
     }
  
     static int max(int a, int b) {
        return Math.max(a, b);
     }
  
     static int ri() {
        try {
           return read.intNext();
        } catch (IOException e) {
           e.printStackTrace();
        }
        System.exit(2);
        return -1;
     }
  
     static long rl() {
        try {
           return Long.parseLong(read.read());
        } catch (IOException e) {
           e.printStackTrace();
        }
        System.exit(2);
        return -1;
     }
  
     static String rs() {
        try {
           return read.read();
        } catch (IOException e) {
           e.printStackTrace();
        }
        System.exit(2);
        return "";
     }
  
     static String rline() {
        try {
           return read.rline();
        } catch (IOException e) {
           e.printStackTrace();
        }
        System.exit(2);
        return "";
     }
  
     static char rc() {
        return rs().charAt(0);
     }
  
     static double rd() {
        try {
           return read.doubleNext();
        } catch (IOException e) {
           e.printStackTrace();
        }
        System.exit(2);
        return -1;
     }
  }
  