Infix to postfix DSA-2

Can someone please help me with my code for infix to postfix conversion.
I am getting a WA.

#include <iostream>
#include <stack>
#include <string>
#include <unordered_map>
using namespace std;

int main() {
	// your code goes here
	int t, n;
	string s;
	unordered_map<char, int> priority;
	priority['$'] = -1;
	priority['('] = 0;
	priority['+'] = 1;
	priority['-'] = 1;
	priority['*'] = 2;
	priority['/'] = 2;
	priority['^'] = 3;
	cin>>t;
	stack <char> expr;
	expr.push('$');
	while(t--){
	    s = "";
	    cin>>n;
	    cin>>s;
	    int len = s.length();
	    for(int i = 0; i < len; i++){
	        if(s[i] >= 'A' && s[i] <= 'Z')
	            cout<<s[i];
	        else if(s[i] == ')'){
	            while(expr.top() != '('){
    	            cout<<expr.top();
    	            expr.pop();
	            }
	            expr.pop();
	        }
	        else{
	            if(s[i] == '(')
	                    expr.push(s[i]);
	            else{
	                if(s[i] != '^'){
	                    while( priority[expr.top()] >= priority[s[i]] )
    	                    {
    	                        cout<<expr.top();
    	                        expr.pop();
    	                    }
    	                    expr.push(s[i]);
	                }
	                else{
	                    expr.push(s[i]);
	                }
	                }
	        }
	    }
	    
	    while(expr.top() != '$')
	    {
	        cout<<expr.top();
	        expr.pop();
	    }
	    cout<<"\n";
	}
	return 0;
}

Link to my submission is: [CodeChef: Practical coding for everyone]