This is the hard version of the problem. The difference between the versions is that the hard version does require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.

Stitch likes experimenting with different machines with his friend Sparky. Today they built another machine.

The main element of this machine are n rods arranged along one straight line and numbered from 1 to n inclusive. Each of these rods must carry an electric charge quantitatively equal to either 1 or -1 (otherwise the machine will not work). Another condition for this machine to work is that the sign-variable sum of the charge on all rods must be zero.

More formally, the rods can be represented as an array of n numbers characterizing the charge: either 1 or -1. Then the condition must hold: a_1 - a_2 + a_3 - a_4 + … = 0, or ∑_{i=1}^n (-1)^{i-1} ⋅ a_i = 0.

Sparky charged all n rods with an electric current, but unfortunately it happened that the rods were not charged correctly (the sign-variable sum of the charge is not zero). The friends decided to leave only some of the rods in the machine. Sparky has q questions. In the ith question Sparky asks: if the machine consisted only of rods with numbers l_i to r_i inclusive, what minimal number of rods could be removed from the machine so that the sign-variable sum of charges on the remaining ones would be zero? Also Sparky wants to know the numbers of these rods. Perhaps the friends got something wrong, and the sign-variable sum is already zero. In that case, you don't have to remove the rods at all.

If the number of rods is zero, we will assume that the sign-variable sum of charges is zero, that is, we can always remove all rods.

Help your friends and answer all of Sparky's questions!

Input

Each test contains multiple test cases.

The first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.

The first line of each test case contains two positive integers n and q (1 ≤ n, q ≤ 3 ⋅ 10^5) — the number of rods and the number of questions.

The second line of each test case contains a non-empty string s of length n, where the charge of the i-th rod is 1 if s_i is the "+" symbol, or -1 if s_i is the "-" symbol.

Each next line from the next q lines contains two positive integers l_i ans r_i (1 ≤ l_i ≤ r_i ≤ n) — numbers, describing Sparky's questions.

It is guaranteed that the sum of n over all test cases does not exceed 3 ⋅ 10^5, and the sum of q over all test cases does not exceed 3 ⋅ 10^5.

It is guaranteed that the sum of the answers (minimal number of rods that can be removed) over all test cases does not exceed 10^6.

Output

For each test case, print the answer in the following format:

In the first line print a single integer k — the minimal number of rods that can be removed.

In the second line print k numbers separated by a space — the numbers of rods to be removed.

If there is more than one correct answer, you can print any.

Example

Input


3
14 1
+--++---++-++-
1 14
14 3
+--++---+++---
1 14
6 12
3 10
4 10
+-+-
1 1
1 2
1 3
1 4
2 2
2 3
2 4
3 3
3 4
4 4


Output


2
5 8
2
1 11
1
9
0
1
1
2
1 2
1
2
2
1 3
1
2
2
2 3
1
3
1
3
2
3 4
1
4

Note

In the first test case for the first query you can remove the rods numbered 5 and 8, then the following set of rods will remain: +--+--++-++-. It is easy to see that here the sign-variable sum is zero.

In the second test case:

  * For the first query, we can remove the rods numbered 1 and 11, then the following set of rods will remain: --++---++---. It is easy to see that here the sign-variable sum is zero. 
  * For the second query we can remove the rod numbered 9, then the following set of rods will remain: ---++-. It is easy to see that here the variable sum is zero. 
  * For the third query we can not remove the rods at all. 
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.io.PrintStream;
            //import java.util.*;

        public class Solution {

            public static final boolean LOCAL = System.getProperty("ONLINE_JUDGE")==null;

            static class FastScanner {

                    BufferedReader br;
                    StringTokenizer st ;

                    FastScanner(){
                        br =  new BufferedReader(new InputStreamReader(System.in));
                        st = new StringTokenizer("");
                    }

                    FastScanner(String file) {

                        try {
                            br =  new BufferedReader(new InputStreamReader(new FileInputStream(file)));
                            st = new StringTokenizer("");
                        } catch (FileNotFoundException e) {
                            // TODO Auto-generated catch block
                            System.out.println("file not found");
                            e.printStackTrace();
                        }
                        
                    }
                    

                    String next() {
                        while (!st.hasMoreTokens())
                            try {
                                st = new StringTokenizer(br.readLine());
                            } catch (IOException e) {
                            }
                        return st.nextToken();
                    }

                    int nextInt() {
                        return Integer.parseInt(next());
                    }

                    long nextLong() {
                        return Long.parseLong(next());
                    }
                    String readLine() throws IOException{
                        return br.readLine();
                    }
                }
                                    
            static class Pair<T,X>{
                T first;
                X second;
                Pair(T first,X second){
                    this.first = first;
                    this.second = second;
                }

                @Override
                public int hashCode(){
                    return Objects.hash(first,second);
                }

                @Override
                public boolean equals(Object obj){
                    return obj.hashCode() == this.hashCode();
                }

            }

        
        public static void main(String[] args) throws Exception {
            
            FastScanner s = new FastScanner();

            
            if(LOCAL){
                s = new FastScanner("src/input.txt");
                PrintStream o = new PrintStream("src/sampleout.txt");
                System.setOut(o);
            }

            int tcr = s.nextInt();

            
            for(int tc=0;tc<tcr;tc++){
                
                int n = s.nextInt();
                
                int q = s.nextInt();

                String str = s.next();

                int pref[] = new int[n];
                
                int turn = 1;

                for(int i=0;i<n;i++){
                    if(str.charAt(i) == '+'){
                        pref[i] = (turn*1) + ((i-1>=0?pref[i-1]:0));
                    }else{
                        pref[i] = (turn*-1) + ((i-1>=0?pref[i-1]:0));
                    }
                    turn = (-turn);
                }

                Map<Integer,TreeSet<Integer>> map = new HashMap<>();

                for(int i=0;i<n;i++){
                    int sum = pref[i] + (i-1 >= 0 ? pref[i-1] : 0);
                    TreeSet<Integer> set = map.getOrDefault(sum,new TreeSet<>());
                    set.add(i);
                    map.put(sum,set);
                }

                //Debug.dbg(pref);

                StringBuilder sb = new StringBuilder();

                for(int i=0;i<q;i++){

                    int l = s.nextInt();

                    int r = s.nextInt();

                    int len = (r - l + 1);

                    l--;
                    r--;

                    int sum_t = pref[r] - ((l-1>=0)?(pref[l-1]):0);

                    if(sum_t == 0){
                        sb.append("0\n");
                    }
                    else if(len % 2 != 0){
                        sb.append("1\n");
                        int sum = pref[r] + ((l-1>=0)?(pref[l-1]):0);

                        int index = map.get(sum).ceiling(l);
                        
                        sb.append((index + 1)+"\n");
                    }else{
                        sb.append("2\n");
                        sb.append((l+1)+" ");
                        l++;
                        int sum = pref[r] + ((l-1>=0)?(pref[l-1]):0);
                        int index = map.get(sum).ceiling(l);
                        sb.append((index + 1)+"\n");
                    }
                }
                print(sb.toString());

            }
            
        }
        

        public static void solve(String curr,int arr[],List<String> list){
            
            boolean finished = true;
            for(int i=0;i<26;i++){
                
                if(arr[i] != 0){
                    finished = false;
                    break;
                }
            } 
            if(finished){
                list.add(curr);
            }

            for(int i=0;i<26;i++){
                if(arr[i] > 0){
                    arr[i]--;
                    solve(curr+((char)('a'+i)),arr,list);
                    arr[i]++;
                }
            }

        }

        public static long modpow(long num,long pow,long mod){

            long val = num;
            long ans = 1l;

            while(pow > 0l){
                
                long bit = pow & 1l;

                if(bit == 1){
                    ans = (ans * (val%mod))%mod;
                }
                val = (val * val) % mod;
                pow = pow >> 1;
            }

            return ans;

        }

        public static char get(int n){
            return (char)('a' + n);
        }

        public static long[] sort(long arr[]){
            List<Long> list = new ArrayList<>();
            for(long n : arr){list.add(n);}
            Collections.sort(list);
            for(int i=0;i<arr.length;i++){
                arr[i] = list.get(i);
            }
            return arr;
        }
        public static int[] sort(int arr[]){
            List<Integer> list = new ArrayList<>();
            for(int n : arr){list.add(n);}
            Collections.sort(list);
            for(int i=0;i<arr.length;i++){
                arr[i] = list.get(i);
            }
            return arr;
        }

        // return the (index + 1)
        // where index is the pos of just smaller element
        // i.e count of elemets strictly less than num
        public static int justSmaller(long arr[],long num){
            //  System.out.println(num+"@");
            int st = 0;
            int e = arr.length - 1;
    
            int ans = -1;
    
            while(st <= e){
    
                int mid = (st + e)/2;
    
                if(arr[mid] >= num){
                    e = mid - 1;
                }else{
                    ans = mid;
                    st = mid + 1;
                }
    
            }
    
    
            return ans + 1;
    
        }
        
        //return (index of just greater element)
        //count of elements smaller than or equal to num

        public static int justGreater(long arr[],long num){
            int st = 0;
            int e = arr.length - 1;
    
            int ans = arr.length;
    
            while(st <= e){
                
                int mid = (st + e)/2;
    
                if(arr[mid] <= num){
                    st = mid + 1;
                }else{
                    ans = mid;
                    e = mid - 1;
                }
            }
    
            return ans;
    
        }
    
        

        public static void println(Object obj){
            System.out.println(obj.toString());
        }

        public static void print(Object obj){
            System.out.print(obj.toString());
        }

        public static int gcd(int a,int b){
            if(b == 0){return a;}
            return gcd(b,a%b);
        }

        public static long gcd(long a,long b){
            if(b == 0l){
                return a;
            }

            return gcd(b,a%b);
        }

        public static int find(int parent[],int v){
            if(parent[v] == v){
                return v;
            }
            
            return parent[v] = find(parent, parent[v]);
        }

    

        public static List<Integer> sieve(){
        
            List<Integer> prime = new ArrayList<>();

            int arr[] = new int[100001];

            Arrays.fill(arr,1);

            arr[1] = 0;
            arr[2] = 1;

            for(int i=2;i<=100000;i++){
                
                if(arr[i] == 1){
                    
                    prime.add(i);

                    for(long j = (i*1l*i);j<100001;j+=i){
                        arr[(int)j] = 0;
                    }
                }
            }

            return prime;
        }

        static boolean isPower(long n,long a){
            
            long log = (long)(Math.log(n)/Math.log(a));

            long power = (long)Math.pow(a,log);

            if(power == n){return true;}

            return false;
        }


        private static int mergeAndCount(int[] arr, int l,int m, int r)
        {

            // Left subarray
            int[] left =  Arrays.copyOfRange(arr, l, m + 1);

            // Right subarray
            int[] right = Arrays.copyOfRange(arr, m + 1, r + 1);

            int i = 0, j = 0, k = l, swaps = 0;

            while (i < left.length && j < right.length) {
                if (left[i] <= right[j])
                    arr[k++] = left[i++];
                else {
                    arr[k++] = right[j++];
                    swaps += (m + 1) - (l + i);
                }
            }
            while (i < left.length)
                arr[k++] = left[i++];
            while (j < right.length)
                arr[k++] = right[j++];
            return swaps;
        }

        // Merge sort function
        private static int mergeSortAndCount(int[] arr, int l,int r)
        {

            // Keeps track of the inversion count at a
            // particular node of the recursion tree
            int count = 0;

            if (l < r) {
                int m = (l + r) / 2;

                // Total inversion count = left subarray count
                // + right subarray count + merge count

                // Left subarray count
                count += mergeSortAndCount(arr, l, m);

                // Right subarray count
                count += mergeSortAndCount(arr, m + 1, r);

                // Merge count
                count += mergeAndCount(arr, l, m, r);
            }

            return count;
        }

        static class Debug {
            //change to System.getProperty("ONLINE_JUDGE")==null; for CodeForces
            public static final boolean LOCAL = System.getProperty("ONLINE_JUDGE")==null;
            private static <T> String ts(T t) {
                if(t==null) {
                    return "null";
                }
                try {
                    return ts((Iterable) t);
                }catch(ClassCastException e) {
                    if(t instanceof int[]) {
                        String s = Arrays.toString((int[]) t);
                        return "{"+s.substring(1, s.length()-1)+"}\n";
                    }else if(t instanceof long[]) {
                        String s = Arrays.toString((long[]) t);
                        return "{"+s.substring(1, s.length()-1)+"}\n";
                    }else if(t instanceof char[]) {
                        String s = Arrays.toString((char[]) t);
                        return "{"+s.substring(1, s.length()-1)+"}\n";
                    }else if(t instanceof double[]) {
                        String s = Arrays.toString((double[]) t);
                        return "{"+s.substring(1, s.length()-1)+"}\n";
                    }else if(t instanceof boolean[]) {
                        String s = Arrays.toString((boolean[]) t);
                        return "{"+s.substring(1, s.length()-1)+"}\n";
                    }
                    try {
                        return ts((Object[]) t);
                    }catch(ClassCastException e1) {
                        return t.toString();
                    }
                }
            }
            private static <T> String ts(T[] arr) {
                StringBuilder ret = new StringBuilder();
                ret.append("{");
                boolean first = true;
                for(T t: arr) {
                    if(!first) {
                        ret.append(", ");
                    }
                    first = false;
                    ret.append(ts(t));
                }
                ret.append("}");
                return ret.toString();
            }
            private static <T> String ts(Iterable<T> iter) {
                StringBuilder ret = new StringBuilder();
                ret.append("{");
                boolean first = true;
                for(T t: iter) {
                    if(!first) {
                        ret.append(", ");
                    }
                    first = false;
                    ret.append(ts(t));
                }
                ret.append("}");
                return ret.toString();
            }
            public static void dbg(Object... o) throws Exception {
                if(LOCAL) {
                    PrintStream ps = new PrintStream("src/Debug.txt");
                    System.setErr(ps);
                    System.err.print("Line #"+Thread.currentThread().getStackTrace()[2].getLineNumber()+": [");
                    for(int i = 0; i<o.length; i++) {
                        if(i!=0) {
                            System.err.print(", ");
                        }
                        System.err.print(ts(o[i]));
                    }
                    System.err.println("]");
                }
            }
        }

}