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.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.StringTokenizer;
  
  
  
  
  public class BalancedSubstrings {
  
      public static void main(String[] args) {
  
          FastScanner f = new FastScanner();
          PrintWriter p = new PrintWriter(System.out);
          int t = f.nextInt();
          while (t-- > 0) {
              int n=f.nextInt();
              char c[]=f.next().toCharArray();
              int l=-1;
              int r=-1;
              boolean found=false;
              for(int i=0;i<n;i++){
                  int a=0;int b=0;
                  if(c[i]=='a') a++;
                  else b++;
                  for(int j=i+1;j<n;j++){
                      if(c[j]=='a') a++;
                      else b++;
                      if(a==b){
                          l=i+1;r=j+1;
                          found=true;
                          break;
                      }
                  }
                  if(found==true) break;
              }
  
              p.print(l+" "+r);
              p.println();
          }
          p.close();
  
      }
  
  //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
  
      static class FastScanner {
          BufferedReader br;
          StringTokenizer st;
  
          public FastScanner() {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
  
      // will work till array size of 65537---fastest sorting time
  //	static long[] radixSort(long[] f) {
  //		return radixSort(f, f.length);
  //	}
  //
  //	static long[] radixSort(long[] f, int n) {
  //		long[] to = new long[n];
  //		{
  //			int[] b = new int[65537];
  //			for (int i = 0; i < n; i++)
  //				b[1 + (int) (f[i] & 0xffff)]++;
  //			for (int i = 1; i <= 65536; i++)
  //				b[i] += b[i - 1];
  //			for (int i = 0; i < n; i++)
  //				to[b[(int) (f[i] & 0xffff)]++] = f[i];
  //			long[] d = f;
  //			f = to;
  //			to = d;
  //		}
  //		{
  //			int[] b = new int[65537];
  //			for (int i = 0; i < n; i++)
  //				b[1 + (int) (f[i] >>> 16 & 0xffff)]++;
  //			for (int i = 1; i <= 65536; i++)
  //				b[i] += b[i - 1];
  //			for (int i = 0; i < n; i++)
  //				to[b[(int) (f[i] >>> 16 & 0xffff)]++] = f[i];
  //			long[] d = f;
  //			f = to;
  //			to = d;
  //		}
  //		{
  //			int[] b = new int[65537];
  //			for (int i = 0; i < n; i++)
  //				b[1 + (int) (f[i] >>> 32 & 0xffff)]++;
  //			for (int i = 1; i <= 65536; i++)
  //				b[i] += b[i - 1];
  //			for (int i = 0; i < n; i++)
  //				to[b[(int) (f[i] >>> 32 & 0xffff)]++] = f[i];
  //			long[] d = f;
  //			f = to;
  //			to = d;
  //		}
  //		{
  //			int[] b = new int[65537];
  //			for (int i = 0; i < n; i++)
  //				b[1 + (int) (f[i] >>> 48 & 0xffff)]++;
  //			for (int i = 1; i <= 65536; i++)
  //				b[i] += b[i - 1];
  //			for (int i = 0; i < n; i++)
  //				to[b[(int) (f[i] >>> 48 & 0xffff)]++] = f[i];
  //			long[] d = f;
  //			f = to;
  //			to = d;
  //		}
  //		return f;
  //	}
  
      // Function to sort an array using quick sort algorithm.
      static void quickSort(long arr[], int low, int high) {
          if (low < high) {
              int p = partition(arr, low, high);
              quickSort(arr, low, p - 1);
              quickSort(arr, p + 1, high);
          }
      }
  
      static int partition(long arr[], int low, int high) {
          long pivot = arr[high];
          int i = low - 1;
          for (int j = low; j < high; j++) {
              if (arr[j] < pivot) {
                  i++;
                  long temp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = temp;
              }
          }
          long temp = arr[i + 1];
          arr[i + 1] = arr[high];
          arr[high] = temp;
  
          return i + 1;
      }
  
      /// Ceils
      static long ceil(long x, long m) {
          long res = x / m;
          if (x % m != 0) {
              res++;
          }
          return res;
      }
  
      // ------------------------------------------------------------------------------------------------
      // makes the prefix sum array
      static long[] prefixSum(long arr[], int n) {
          long psum[] = new long[n];
          psum[0] = arr[0];
          for (int i = 1; i < n; i++) {
              psum[i] = psum[i - 1] + arr[i];
          }
          return psum;
      }
      // ------------------------------------------------------------------------------------------------
  
      // makes the suffix sum array
      static long[] suffixSum(long arr[], int n) {
          long ssum[] = new long[n];
          ssum[n - 1] = arr[n - 1];
          for (int i = n - 2; i >= 0; i--) {
              ssum[i] = ssum[i + 1] + arr[i];
          }
          return ssum;
      }
  
  //------------------------------------------------------------------------------------------
      // BINARY EXPONENTIATION OF A NUMBER MODULO M FASTER METHOD WITHOUT RECURSIVE
      // OVERHEADS
  //	static long m = (long) (1e9 + 7);
  
      static long binPower(long a, long n, long m) {
          if (n == 0)
              return 1;
          long res = 1;
          while (n > 0) {
              if ((n & 1) != 0) {
                  res *= a;
              }
              a *= a;
              n >>= 1;
          }
          return res;
      }
  
  //-------------------------------------------------------------------------------------------
  
      // gcd
      static long gcd(long a, long b) {
          return b == 0 ? a : gcd(b, a % b);
      }
  
  //------------------------------------------------------------------------------------------
  
      // lcm
      static long lcm(long a, long b) {
          return a / gcd(a, b) * b;
      }
  
      //------------------------------------------------------------------------------------------
      // BRIAN KERNINGHAM TO CHECK NUMBER OF SET BITS
      // O(LOGn)
      static int setBits(int n) {
          int count = 0;
          while (n > 0) {
              n = n & (n - 1);
              count++;
          }
          return count;
      }
  //------------------------------------------------------------------------------------------
  
      //------------------------------------------------------------------------------------------
      // 0 based indexing
      static boolean KthBitSet(int n, int k) {
          int mask = 1;
          mask = mask <<= k;
          if ((mask & n) != 0)
              return true;
          else
              return false;
      }
  
  //------------------------------------------------------------------------------------------
  
      // EXTENDED EUCLIDEAN THEOREM
      // TO REPRESENT GCD IN TERMS OF A AND B
      // gcd(a,b) = a.x + b.y where x and y are integers
  
      static long x = -1;
      static long y = -1;
  
      static long gcdxy(long a, long b) {
          if (b == 0) {
              x = 1;
              y = 0;
              return a;
          } else {
              long d = gcdxy(b, a % b);
              long x1 = y;
              long y1 = x - (a / b) * y;
              x = x1;
              y = y1;
  
              return d;
          }
      }
  
  //-------------------------------------------------------------------------------------------------F
  }
  
  