package codeforces1230;

import java.util.Scanner;

public class B {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        String a = in.next();
        if (k == 0) System.out.println(a);
        else if (n == 1) System.out.println(0);
        else {
            System.out.print(1);
            k -= (a.charAt(0) != '1' ? 1 : 0);
            int i = 1;
            for (; i<n && k != 0; i++) {
                if (a.charAt(i) != '0') k--;
                System.out.print(0);
            }
            for (; i<n; i++) {
                System.out.print(a.charAt(i));
            }
        }
    }
}


import java.util.Scanner;

public class main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        String a = in.next();
        if (k == 0) System.out.println(a);
        else if (n == 1) System.out.println(0);
        else {
            System.out.print(1);
            int i = 1;
            for (; i<n && i < k; i++) {
                System.out.print(0);
            }
            for (; i<n; i++) {
                System.out.print(a.charAt(i));
            }
        }
    }
}


import java.util.Scanner;

public class main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        String a = in.next();
        if (k == 0) System.out.println(a);
        else if (n == 1) System.out.println(0);
        else {
            System.out.print(1);
            k -= (a.charAt(0) != '1' ? 1 : 0);
            int i = 1;
            for (; i<n && k != 0; i++) {
                if (a.charAt(i) != '0') k--;
                System.out.print(0);
            }
            for (; i<n; i++) {
                System.out.print(a.charAt(i));
            }
        }
    }
}


/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.*;

public class HelloWorld{

    public static void main(String[] args) throws IOException
    {

        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
            int l=input.nextInt();
            int k=input.nextInt();
            StringBuilder res=new StringBuilder();
            String s=input.next();
            if(l==1){
                if(k==0){
                    System.out.println(s);
                    continue;
                }
                System.out.println("0");
                continue;
            }
            for(int i=0;i<l;i++){
                if(k==0){
                    res.append(s.charAt(i));
                    continue;
                }
                if(i==0){

                    if(s.charAt(i)=='1'){
                        res.append(s.charAt(i));
                        continue;
                    }
                    res.append('1');
                    k--;
                    continue;
                }
                if(s.charAt(i)=='0'){
                    res.append('0');
                    continue;
                }
                res.append('0');
                k--;
            }
            System.out.println(res.toString());
        }

    }

}


import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class forces{
    public static void main(String args[])throws IOException{
        DataInputStream ins=new DataInputStream(System.in);
		String s[]=ins.readLine().split(" ");
		int n=Integer.parseInt(s[0]);
		int k=Integer.parseInt(s[1]);
		String x[]=ins.readLine().split("");
		if(n==k){
			for(int i=0;i<n;i++){
				x[i]="0";
			}
		}
		else{
			if(x[0].equals("1")){
				for(int i=1;i<=k;i++){
					x[i]="0";
				}
			}
			else{
				x[0]="1";
				for(int i=1;i<k;i++){
					x[i]="0";
				}
			}
		}
		StringBuffer br=new StringBuffer();
		for(int i=0;i<n;i++){
			br.append(x[i]);
		}
		System.out.println(br);
	}
}

/*

*/


import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class forces{
    public static void main(String args[])throws IOException{
        DataInputStream ins=new DataInputStream(System.in);
		String s[]=ins.readLine().split(" ");
		int n=Integer.parseInt(s[0]);
		int k=Integer.parseInt(s[1]);
		String x[]=ins.readLine().split("");
		if(n==k){
			if(n==1){
				x[0]="0";
			}
			else{
				x[0]="1";
			}
			for(int i=1;i<n;i++){
				x[i]="0";
			}
		}
		else{
			if(x[0].equals("1")){
				int filler=1,ind=1;
				while(filler<=k && ind<n){
					if(!x[ind].equals("0")){
						x[ind]="0";
						filler++;
					}
					ind++;
				}
			}
			else{
				if(k>0){
					x[0]="1";
					int filler=2,ind=1;
					while(filler<=k && ind<n){
						if(!x[ind].equals("0")){
							x[ind]="0";
							filler++;
						}
						ind++;
					}
				}
			}
		}
		StringBuffer br=new StringBuffer();
		for(int i=0;i<n;i++){
			br.append(x[i]);
		}
		System.out.println(br);
	}
}

/*

*/


import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class forces{
    public static void main(String args[])throws IOException{
        DataInputStream ins=new DataInputStream(System.in);
		String s[]=ins.readLine().split(" ");
		int n=Integer.parseInt(s[0]);
		int k=Integer.parseInt(s[1]);
		String x[]=ins.readLine().split("");
		if(n==k){
			x[0]="1";
			for(int i=1;i<n;i++){
				x[i]="0";
			}
		}
		else{
			if(x[0].equals("1")){
				int filler=1,ind=1;
				while(filler<=k && ind<n){
					if(!x[ind].equals("0")){
						x[ind]="0";
						filler++;
					}
					ind++;
				}
			}
			else{
				if(k>0){
					x[0]="1";
					int filler=2,ind=1;
					while(filler<=k && ind<n){
						if(!x[ind].equals("0")){
							x[ind]="0";
							filler++;
						}
						ind++;
					}
				}
			}
		}
		StringBuffer br=new StringBuffer();
		for(int i=0;i<n;i++){
			br.append(x[i]);
		}
		System.out.println(br);
	}
}

/*

*/


import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class forces{
    public static void main(String args[])throws IOException{
        DataInputStream ins=new DataInputStream(System.in);
		String s[]=ins.readLine().split(" ");
		int n=Integer.parseInt(s[0]);
		int k=Integer.parseInt(s[1]);
		String x[]=ins.readLine().split("");
		if(n==k){
			for(int i=0;i<n;i++){
				x[i]="0";
			}
		}
		else{
			if(x[0].equals("1")){
				int filler=1,ind=1;
				while(filler<=k && ind<n){
					if(!x[ind].equals("0")){
						x[ind]="0";
						filler++;
					}
					ind++;
				}
			}
			else{
				if(k>0){
					x[0]="1";
					int filler=2,ind=1;
					while(filler<=k && ind<n){
						if(!x[ind].equals("0")){
							x[ind]="0";
							filler++;
						}
						ind++;
					}
				}
			}
		}
		StringBuffer br=new StringBuffer();
		for(int i=0;i<n;i++){
			br.append(x[i]);
		}
		System.out.println(br);
	}
}

/*

*/


/** author : SanskarxRawat
**/
import java.util. * ;

public class solution {
	public static void main(String[] args) {
		Scanner in =new Scanner(System. in );
		int n = in.nextInt();
		int k = in.nextInt();
		String S = in.next();
		char[] arr = S.toCharArray();
		int counter = 0;
		if (n == 1) System.out.print(0);
		else if (k == 0) System.out.print(S);
		else {

			if (arr[0] != 1) {
				arr[0] = '1';
				counter++;
			}
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != '0') {
					arr[i] = '0';
					counter++;
				}
				if (counter == k) break;
				else continue;
			}
			for (char ans: arr)
			System.out.print(ans);
		}
	}
}


/** author : SanskarxRawat
**/
import java.util. * ;

public class solution {
	public static void main(String[] args) {
		Scanner in =new Scanner(System. in );
		int n = in.nextInt();
		int k = in.nextInt();
		String S = in.next();
		char[] arr = S.toCharArray();
		int counter = 0;

		if (k == 0) System.out.print(S);
		else if (n == 1) System.out.print(0);
		else {

			if (arr[0] != '1') {
				arr[0] = '1';
				counter++;
			}
			for (int i = 1; i < arr.length; i++) {
				if (counter == k) break;
				else if (arr[i] != '0') {
					arr[i] = '0';
					counter++;
				}
			}
			for (char ans: arr)
			System.out.print(ans);
		}
	}
}


/** author : SanskarxRawat
**/
import java.util. * ;

public class solution {
	public static void main(String[] args) {
		Scanner in =new Scanner(System. in );
		int n = in.nextInt();
		int k = in.nextInt();
		String S = in.next();
		char[] arr = S.toCharArray();
		int counter = 0;

		if (k == 0) System.out.print(S);
		else if (n == 1) System.out.print(0);
		else {

			if (arr[0] != 1) {
				arr[0] = '1';
				counter++;
			}
			for (int i = 1; i < arr.length; i++) {
				if (counter == k) break;
				else if (arr[i] != '0') {
					arr[i] = '0';
					counter++;
				}
			}
			for (char ans: arr)
			System.out.print(ans);
		}
	}
}


/** author : SanskarxRawat
**/
import java.util. * ;

public class solution {
	public static void main(String[] args) {
		Scanner in =new Scanner(System. in );
		int n = in.nextInt();
		int k = in.nextInt();
		String S = in.next();
		char[] arr = S.toCharArray();
		int counter = 0;

		if (k == 0) System.out.print(S);
		else if (n == 1) System.out.print(0);
		else {

			if (arr[0] != 1) {
				arr[0] = '1';
				counter++;
			}
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != '0') {
					arr[i] = '0';
					counter++;
				}
				if (counter == k) break;
				else continue;
			}
			for (char ans: arr)
			System.out.print(ans);
		}
	}
}


import java.util.Scanner;

public class main {

    public static void main(String[] args) {
       int n,x,y,z,cnt=0,s,b,c=1;
       Scanner in=new Scanner (System.in);
       n=in.nextInt();
       s=in.nextInt();
     String  a=in.next();
     if(n==1 && s==1)
     {
        System.out.println("0");
        System.exit(0);
     }
     if(n==1 && s==0)
     {
        System.out.println(a);
        System.exit(0);
     }

            if(a.charAt(0)!='1')
             {
                System.out.print("1");
                s--;

             }
            else  if(a.charAt(0)=='1')
             {
                System.out.print("1");

             }

         for(int i=1;i<n;i++)
         {

            if(a.charAt(i)!='0' && s!=0)
             {
                System.out.print("0");
                s--;
                c++;

             }
             else if(a.charAt(i)=='0' && s!=0)
             {
                System.out.print("0");
                c++;
             }
             else if(s==0)
             {
                 System.out.print(a.charAt(i));
             }
         }

    System.out.println() ;

    }

}


import java.util.Scanner;

public class main {

    public static void main(String[] args) {
       int n,x,y,z,cnt=0,s,b,c=1;
       Scanner in=new Scanner (System.in);
       n=in.nextInt();
       s=in.nextInt();
     String  a=in.next();
     if(n==1 && s==1)
     {
        System.out.println("0");
        System.exit(0);
     }
            if(a.charAt(0)!='1')
             {
                System.out.print("1");
                s--;

             }
            else  if(a.charAt(0)=='1')
             {
                System.out.print("1");

             }

         for(int i=1;i<n;i++)
         {

            if(a.charAt(i)!='0' && s!=0)
             {
                System.out.print("0");
                s--;
                c++;

             }
             else if(a.charAt(i)=='0' && s!=0)
             {
                System.out.print("0");
                c++;
             }
             else if(s==0)
             {
                 System.out.print(a.charAt(i));
             }
         }

    System.out.println() ;

    }

}


import java.util.Scanner;

public class main {

    public static void main(String[] args) {
       int n,x,y,z,cnt=0,s,b,c=1;
       Scanner in=new Scanner (System.in);
       n=in.nextInt();
       s=in.nextInt();
     String  a=in.next();
     if(n==1 && s==1)
     {
        System.out.println("0");
        System.exit(0);
     }
     if( s==0)
     {
        System.out.println(a);
        System.exit(0);
     }

            if(a.charAt(0)!='1')
             {
                System.out.print("1");
                s--;

             }
            else  if(a.charAt(0)=='1')
             {
                System.out.print("1");

             }

         for(int i=1;i<n;i++)
         {

            if(a.charAt(i)!='0' && s!=0)
             {
                System.out.print("0");
                s--;
                c++;

             }
             else if(a.charAt(i)=='0' && s!=0)
             {
                System.out.print("0");
                c++;
             }
             else if(s==0)
             {
                 System.out.print(a.charAt(i));
             }
         }

    System.out.println() ;

    }

}


import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        char[] s = br.readLine().toCharArray();
        if (n==1 && k>=0) System.out.println(0);
        else{
            int p = 0;
            while (p < n && k > 0){
                if (p==0){
                    if (s[p]!='1') k--;
                    s[0] = '1';
                }
                else{
                    if (s[p]!='0') k--;
                    s[p] = '0';
                }
                p++;

            }
        }
        StringBuilder sb = new StringBuilder();
        for (char c : s) sb.append(c);
        System.out.println(sb.toString());
        br.close();
    }
}


import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        String[] s = br.readLine().split(" ");
        if (n==1 && k>=0) pw.println(0);
        else{
            s[0] = "1";
            for (int i = 1; i < k && i < n; i++) s[i] = "0";
        }
        StringBuilder sto = new StringBuilder();
        for (String i : s) sto.append(i);

        pw.println(sto);
        br.close();
        pw.flush();
    }
}


import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        String str = br.readLine();
        char[] s = str.toCharArray();
        if (k==0) System.out.println(str);
        else if (n==1 && k>0) System.out.println(0);
        else{
            int p = 0;
            while (p < n && k > 0){
                if (p==0){
                    if (s[p]!='1') k--;
                    s[0] = '1';
                }
                else{
                    if (s[p]!='0') k--;
                    s[p] = '0';
                }
                p++;

            }

        StringBuilder sb = new StringBuilder();
        for (char c : s) sb.append(c);
        System.out.println(sb.toString());}
        br.close();
    }
}


import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        char[] s = br.readLine().toCharArray();
        if (n==1 && k>=0) System.out.println(0);
        else{
            s[0] = '1';
            for (int i = 1; i < k && i < n; i++) s[i] = '0';
        }
        StringBuilder sb = new StringBuilder();
        for (char c : s) sb.append(c);
        System.out.println(sb.toString());
        br.close();
    }
}


import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        char[] s = br.readLine().toCharArray();
        if (n==1 && k>=0) System.out.println(0);
        else{
            int p = 0;
            while (p < n && k > 0){
                if (p==0){
                    if (s[p]!='1') k--;
                    s[0] = '1';
                }
                else{
                    if (s[p]!='0') k--;
                    s[p] = '0';
                }
                p++;

            }

        StringBuilder sb = new StringBuilder();
        for (char c : s) sb.append(c);
        System.out.println(sb.toString());}
        br.close();
    }
}


import java.util.*;
import java.io.*;

public class B588 {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int k = sc.nextInt();
        String s = sc.next();
        int [] a = new int [n];
        for (int i = 0; i < n; i++) a[i] = s.charAt(i) - 48;
        if (n == 1) {
            if (k > 0) System.out.println(0);
            else System.out.println(s);
            return;
        }
        int cur = 0; int changed = 0;
        while (changed < k && cur < n) {
            if (cur == 0) {
                if (a[cur] != 1) changed++;
                a[cur] = 1;
            } else {
                if (a[cur] != 0) changed++;
                a[cur] = 0;
            }
            cur++;
        }
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < n; i++) ret.append(a[i]);
        out.println(ret.toString());
        out.close();
    }

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }

    }

}


import java.util.*;
import java.io.*;

public class B588 {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int k = sc.nextInt();
        String s = sc.next();
        int [] a = new int [n];
        for (int i = 0; i < n; i++) a[i] = s.charAt(i) - 48;
        if (n == 1) {
            if (k > 0) System.out.println(0);
            else System.out.println(s);
            return;
        }
        int cur = 0; int changed = 0;
        while (changed < k && cur < n) {
            if (cur == 0) {
                if (a[cur] != 1) changed++;
                a[cur] = 1;
            } else {
                if (a[cur] != 0) changed++;
                a[cur] = 0;
            }
            cur++;
        }
        String ret = "";
        for (int i = 0; i < n; i++) ret += a[i];
        out.println(ret);
        out.close();
    }

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }

    }

}


import java.util.*;
import java.math.BigInteger;
import java.io.*;
public class minimise // round #588 div2
{
    public static void main(String[] args)  throws IOException
    {
        Scanner sc=new Scanner(System.in);
        PrintWriter write=new PrintWriter(System.out);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String num=sc.next();
        char a[]=num.toCharArray();
        for(int i=0;i<n;i++)
        {
            if(k==0)
            break;
            else
            {
                if(a[i]=='0' || (i==0 && a[i]=='1'))
                continue;
                else{
                k--;
                if(a[i]!='0')
                a[i]='0';
                if(i==0)
                a[i]='1';
                if(i==n-1)
                a[i]='0';
                }
            }
        }
        for(char c : a)
            System.out.print(c);
        write.close();
    }
}


import java.util.*;
import java.math.BigInteger;
import java.io.*;
public class minimise // round #588 div2
{
    public static void main(String[] args)  throws IOException
    {
        Scanner sc=new Scanner(System.in);
        PrintWriter write=new PrintWriter(System.out);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String num=sc.next();
        char a[]=num.toCharArray();
        for(int i=0;i<n;i++)
        {
            if(k==0)
            break;
            else
            {
                if(a[i]=='0')
                continue;
                else{
                k--;
                if(a[i]!='0')
                a[i]='0';
                if(i==0)
                a[i]='1';
                if(i==n-1)
                a[i]='0';
                }
            }
        }
        for(char c : a)
            System.out.print(c);
        write.close();
    }
}


for _ in range(input()):
    n = int(raw_input())
    s = raw_input()
    if len(set([ch for ch in s])) == 1:
        print(n)
        continue
    ok = [False]*n
    for i in range(n):
        if s[i] == '-' or s[i-1] == '-':
            ok[i] = True
    print(len([x for x in ok if x]))


for _ in range(input()):
    n = int(raw_input())
    s = raw_input()
    if len(set([ch for ch in s])) == 1 or '<' not in s or '>' not in s:
        print(n)
        continue
    ok = [False]*n
    for i in range(n):
        if s[i] == '-' or s[i-1] == '-':
            ok[i] = True
    print(len([x for x in ok if x]))


from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
import sys
sys.setrecursionlimit(10**4)
# sys.stdin = open('inpy.txt', 'r')
# sys.stdout = open('outpy.txt', 'w')
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
i_m=9223372036854775807
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
import math
def GCD(x, y):
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y):
        x, y = y, x % y
    return x
def Divisors(n) :
    l = []
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) :
            if (n // i == i) :
                l.append(i)
            else :
                l.append(i)
                l.append(n//i)
    return l
prime=[]
def SieveOfEratosthenes(n):
    global prime
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n):
        if prime[p]:
            f.append(p)
    return f
def primeFactors(n):
    a=[]
    # Print the number of two's that divide n
    while n % 2 == 0:
        a.append(2)
        n = n // 2

    # n must be odd at this point
    # so a skip of 2 ( i = i + 2) can be used
    for i in range(3,int(math.sqrt(n))+1,2):

        # while i divides n , print i ad divide n
        while n % i== 0:
            a.append(i)
            n = n // i

    # Condition if n is a prime
    # number greater than 2
    if n > 2:
        a.append(n)
    return a
"""*******************************************************"""
def main():
    t=inin()
    for _ in range(t):
        n=inin()
        s=sin()
        if len(set(s))==1:
            print(n)
        else:
            a=[0]*n
            for i in range(n):
                if s[i]=='-':
                    a[i]=1
                    a[(i+1)%n]=1
            print(sum(a))

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is yferent which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'R' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'R' [0]:
        A.append(sign*numb)
    return A

# threading.Thread(target=main).start()
if __name__== "__main__":
  main()


from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
import sys
sys.setrecursionlimit(10**4)
# sys.stdin = open('inpy.txt', 'r')
# sys.stdout = open('outpy.txt', 'w')
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
i_m=9223372036854775807
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
import math
def GCD(x, y):
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y):
        x, y = y, x % y
    return x
def Divisors(n) :
    l = []
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) :
            if (n // i == i) :
                l.append(i)
            else :
                l.append(i)
                l.append(n//i)
    return l
prime=[]
def SieveOfEratosthenes(n):
    global prime
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n):
        if prime[p]:
            f.append(p)
    return f
def primeFactors(n):
    a=[]
    # Print the number of two's that divide n
    while n % 2 == 0:
        a.append(2)
        n = n // 2

    # n must be odd at this point
    # so a skip of 2 ( i = i + 2) can be used
    for i in range(3,int(math.sqrt(n))+1,2):

        # while i divides n , print i ad divide n
        while n % i== 0:
            a.append(i)
            n = n // i

    # Condition if n is a prime
    # number greater than 2
    if n > 2:
        a.append(n)
    return a
"""*******************************************************"""
def main():
    t=inin()
    for _ in range(t):
        n=inin()
        s=sin()
        ss=[]
        for i in s:
            if i!="-":
                ss.append(i)
        if len(set(ss))==1:
            print(n)
        else:
            a=[0]*n
            for i in range(n):
                if s[i]=='-':
                    a[i]=1
                    a[(i+1)%n]=1
            print(sum(a))

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is yferent which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'R' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'R' [0]:
        A.append(sign*numb)
    return A

# threading.Thread(target=main).start()
if __name__== "__main__":
  main()


from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
import sys
sys.setrecursionlimit(10**4)
# sys.stdin = open('inpy.txt', 'r')
# sys.stdout = open('outpy.txt', 'w')
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
i_m=9223372036854775807
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
import math
def GCD(x, y):
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y):
        x, y = y, x % y
    return x
def Divisors(n) :
    l = []
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) :
            if (n // i == i) :
                l.append(i)
            else :
                l.append(i)
                l.append(n//i)
    return l
prime=[]
def SieveOfEratosthenes(n):
    global prime
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n):
        if prime[p]:
            f.append(p)
    return f
def primeFactors(n):
    a=[]
    # Print the number of two's that divide n
    while n % 2 == 0:
        a.append(2)
        n = n // 2

    # n must be odd at this point
    # so a skip of 2 ( i = i + 2) can be used
    for i in range(3,int(math.sqrt(n))+1,2):

        # while i divides n , print i ad divide n
        while n % i== 0:
            a.append(i)
            n = n // i

    # Condition if n is a prime
    # number greater than 2
    if n > 2:
        a.append(n)
    return a
"""*******************************************************"""
def main():
    t=inin()
    for _ in range(t):
        n=inin()
        s=sin()
        ss=""
        for i in s:
            if i!="-":
                ss+=i
        if len(set(ss))==1:
            print(n)
        else:
            a=[0]*n
            for i in range(n):
                if s[i]=='-':
                    a[i]=1
                    a[(i+1)%n]=1
            print(sum(a))

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is yferent which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'R' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'R' [0]:
        A.append(sign*numb)
    return A

# threading.Thread(target=main).start()
if __name__== "__main__":
  main()


import sys
if sys.subversion[0] == "PyPy":
    import io, atexit
    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()

RS = raw_input
RI = lambda x=int: map(x,RS().split())
RN = lambda x=int: x(RS())
''' ...................................................................... '''

for _ in xrange(RN()):
    n = RN()
    num = RS()

    cycle = True
    ss = set(num)
    if len(ss)==3:
        cycle = False
    elif len(ss)==2 and '-' not in ss:
        cycle = False

    if cycle:
        print n
        continue

    ans = 0
    yes = [0]*n

    for i in xrange(n):
        if num[i]=='-':
            yes[i] = 1
            yes[(i+1)%n] = 1

    print sum(yes)


FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO = "Yes", "No"
from collections import defaultdict as ddic

def solve(N, S):
    if ('<' not in S) or ('>' not in S):
        return N

    A = [False] * N
    for i, c in enumerate(S):
        if c == '-':
            A[i] = True
            A[i - 1] = True
    return sum(A)

for TC in xrange(rri()):
    N = rri()
    print solve(N, rr())


for _ in range(input()):
    n=input()
    s=raw_input()
    cnt=0
    if '>' not in s or '<' not in s:
        cnt=n
    else:
        for i in range(n):
            if '-' in [s[i%n],s[(i+1)%n]]:
                cnt+=1
    print cnt


import atexit, io, sys

# A stream implementation using an in-memory bytes
# buffer. It inherits BufferedIOBase.
buffer = io.BytesIO()
sys.stdout = buffer

# print via here
@atexit.register
def write():
    sys.__stdout__.write(buffer.getvalue())
for _ in range(input()):
    n=input()
    a=raw_input()
    if ">" not in a or "<" not in a:
        print n;continue

    ans=0
    poss=[0 for j in range(n)]
    for i in range(n):
        if( a[i]=="-"):
            poss[i]=1;poss[(i+1)%n]=1

    print sum(poss)


import atexit, io, sys

# A stream implementation using an in-memory bytes
# buffer. It inherits BufferedIOBase.
buffer = io.BytesIO()
sys.stdout = buffer

# print via here
@atexit.register
def write():
    sys.__stdout__.write(buffer.getvalue())
for _ in range(input()):
    n=input()
    a=raw_input()
    if a==">"*n or a=="<"*n or a=="-"*n:
        print n;continue

    ans=0
    poss=[0 for j in range(n)]
    for i in range(n):
        if( a[i]=="-"):
            poss[i]=1;poss[(i+1)%n]=1

    print sum(poss)


import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

for _ in xrange(int(input())):
    n = int(input())
    s = input()
    returnable = [False for _ in xrange(n)]
    first_time = True
    ok1 = True
    ok2 = True
    for i in xrange(n):
        if s[i] == '-':
            returnable[i] = True
            if first_time:
                returnable[(i+1)%n] = True
                first_time = False
        elif s[i] == '>':
            ok1 = False
            first_time = True
        else:
            first_time = True
            ok2 = False
    if ok1 or ok2:
        ans = n
    else:
        ans = sum(returnable)
    print(ans)


import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

for _ in xrange(int(input())):
    n = int(input())
    s = input()
    returnable = [False for _ in xrange(n)]
    ok1 = True
    ok2 = True
    for i in xrange(n):
        if s[i] == '-':
            returnable[i] = True
            returnable[(i+1)%n] = True
        elif s[i] == '>':
            ok1 = False
        else:
            ok2 = False
    if ok1 or ok2:
        ans = n
    else:
        ans = sum(returnable)
    print(ans)


    for something in range(int(input())):
        n = int(input())
        s = input()
        if '>' in s and '<' in s:
            if s.count('-') != 0:
                print(s.count('-') + 1)
            else:
                print(0)
        else:
            print(n)


for something in range(int(input())):
    n = int(input())
    s = input()
    if '>' in s and '<' in s:
        ans = 0
        for i in range(n):
            if s[i] == '-':
                ans += 3
                if s[i - 1] == '-':
                    ans -= 1
                if s[(i + 1] % n] == '-':
                ans -= 1
        print(ans)
    else:
        print(n)


for something in range(int(input())):
    n = int(input())
    s = input()
    if '>' in s and '<' in s:
        ans = 0
        i = 0
        while i < n:
            if s[i] == '-':
                ans += 3
                if s[i - 1] == '-':
                    ans -= 1
                if s[(i + 1] % n] == '-':
                    ans -= 1
                else:
                    if a[(i + 2) % n] == '-':
                        ans -= 1
            i += 1
        print(ans)
    else:
        print(n)


for something in range(int(input())):
    n = int(input())
    s = input()
    if '>' in s and '<' in s:
        ans = 0
        i = 0
        while i < n:
            if s[i] == '-':
                ans += 3
                if s[i - 1] == '-':
                    ans -= 1
                if s[(i + 1) % n] == '-':
                    ans -= 1
                else:
                    if s[(i + 2) % n] == '-':
                        ans -= 1
            i += 1
        print(ans)
    else:
        print(n)


    for something in range(int(input())):
        n = int(input())
        s = input()
        if '>' in s and '<' in s:
            ans = 0
            for i in range(n):
                if s[i] == '-':
                    ans += 3
                    if s[i - 1] == '-':
                        ans -= 1
                    if s[(i + 1] % n] == '-':
                        ans -= 1
            print(ans)
        else:
            print(n)


for something in range(int(input())):
    n = int(input())
    s = input()
    if '>' in s and '<' in s:
        if s.count('-') != 0:
            print(s.count('-') + 1)
        else:
            print(0)
    else:
        print(n)


for something in range(int(input())):
    n = int(input())
    s = input()
    if '>' in s and '<' in s:
        print(s.count('-') + 1)
    else:
        print(n)


for something in range(int(input())):
    n = int(input())
    s = input()
    if '>' in s and '<' in s:
        ans = 0
        for i in range(n):
            if s[i] == '-' or s[i - 1] == '-':
                ans += 1
        print(ans)
    else:
        print(n)


for something in range(int(input())):
    n = int(input())
    s = input()
    if '>' in s and '<' in s:
        ans = 0
        i = 0
        while i < n:
            if s[i] == '-':
                ans += 3
                if s[i - 1] == '-':
                    ans -= 1
                if s[(i + 1) % n] == '-':
                    ans -= 1
                else:
                    if a[(i + 2) % n] == '-':
                        ans -= 1
            i += 1
        print(ans)
    else:
        print(n)


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)
def put():  return  map(int, stdin.readline().split())
for _ in range(int(input())):
	n=int(input())
	s=input()
	if(s.count("<")==n or s.count(">")==n):
		print(n)
	else:
		sm=0
		ans=0
		for i in s:
			if(i=="-"):
				sm+=1
			elif(sm>0):
				ans+=sm+1
				sm=0
		if(sm>0):
			ans+=sm+1
		if(s[0]=="-" and s[-1]=="-"):
			ans-=1
		print(ans)


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)
def put():  return  map(int, stdin.readline().split())
for _ in range(int(input())):
	n=int(input())
	s=input()
	if(n==1):
		print(0)

	elif(s.count("<")==n or s.count(">")==n):
		print(n)
	else:
		sm=0
		ans=0
		for i in s:
			if(i=="-"):
				sm+=1
			elif(sm>0):
				ans+=sm+1
				sm=0
		if(sm>0):
			ans+=sm+1
		if(s[0]=="-" and s[-1]=="-"):
			ans-=1
		print(ans)


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)
def put():  return  map(int, stdin.readline().split())
for _ in range(int(input())):
	n=int(input())
	s=input()
	if(s.count("<")==0 or s.count(">")==0):
		print(n)
	else:
		sm=0
		ans=0
		for i in s:
			if(i=="-"):
				sm+=1
			elif(sm>0):
				ans+=sm+1
				sm=0
		if(sm>0):
			ans+=sm+1
		if(s[0]=="-" and s[-1]=="-"):
			ans-=1
		print(ans)


test_cases=int(input())
for test_case in range(test_cases):
    n = (int(input()))
    s=input()
    a=sorted(s)

    z=0

    alone=0
    together=0

    if a[-1]=='>':
        for i in s:
            if i =='<':
                z=1
                break
    if z==1:
        for i in range(n):
            # print(s[i])
            if s[i]=='-':
                # print(1)
                if i!=0 and i!=n-1:
                    # print(2)
                    if s[i+1]=='-' or s[i-1]=='-':
                        together+=1
                    else:
                        alone+=1
                else:
                    # print(3)
                    if i==0:
                        if s[i+1]=='-' or s[n-1]=='-':
                            together+=1
                        else:
                            alone+=1
                    elif i==n-1:
                        if s[i-1]=='-' or s[0]=='-':
                            together+=1
                        else:
                            alone+=1
        if together>0:
            print((alone*2)+(together+1))
        else:
            print(alone*2)
    else:
        print(n)

    # print(a,z)


test_cases=int(input())
for test_case in range(test_cases):
    n = (int(input()))
    s=input()

    z=0
    x=0
    ans=0
    for i in s:
        if z==1 and x==1:
            break
        elif i=='<':
            z=1
        elif i=='>':
            x=1

    if z==1 and x==1:
        for i in range(n):
            s+=s[0]
            if s[i]=='-' or s[i+1]=='-':
                ans+=1
        print(ans)
    else:
        print(n)

    # print(a,z)


test_cases=int(input())
for test_case in range(test_cases):
    n = (int(input()))
    s=input()
    a=sorted(s)

    z=0
    ans=0
    if a[-1]=='>':
        for i in s:
            if i =='<':
                z=1
                break
    if z==1:
        for i in range(n):
            s+=s[0]
            if s[i]=='-' or s[i+1]=='-':
                ans+=1
        print(ans)
    else:
        print(n)

    # print(a,z)


test_cases=int(input())
for test_case in range(test_cases):
    n = (int(input()))
    s=input()
    a=sorted(s)
    ans=0
    z=0
    count=0
    alone=0
    together=0

    if a[-1]=='>':
        for i in s:
            if i =='<':
                z=1
                break
    if z==1:
        for i in range(n):
            # print(s[i])
            if s[i]=='-':
                # print(1)
                if i!=0 and i!=n-1:
                    # print(2)
                    if s[i+1]=='-' or s[i-1]=='-':
                        together+=1
                    else:
                        alone+=1
                else:
                    # print(3)
                    if i==0:
                        if s[i+1]=='-' or s[n-1]=='-':
                            together+=1
                        else:
                            alone+=1
                    elif i==n-1:
                        if s[i-1]=='-' or s[0]=='-':
                            together+=1
                        else:
                            alone+=1
        if together>0:
            print((alone*2)+(together+1))
        else:
            print(alone*2)
    else:
        print(n)

    # print(z)


test_cases=int(input())
for test_case in range(test_cases):
    n = (int(input()))
    s=input()

    z=0
    x=0
    ans=0
    for i in s:
        if z==1 and x==1:
            break
        elif i=='<':
            z=1
        elif i=='>':
            x=1

    if z==1 and x==1:
        s += s[0]
        for i in range(n):

            if s[i]=='-' or s[i+1]=='-':
                ans+=1
        print(ans)
    else:
        print(n)

    # print(a,z)


test_cases=int(input())
for test_case in range(test_cases):
    n = (int(input()))
    s=input()
    a=sorted(s)
    ans=0
    z=0
    count=0
    alone=0
    together=0
    if a[-1]=='<':
        z=1
    elif a[-1]=='>':
        for i in s:
            if i =='<':
                z=1
                break
    elif a[-1]=='-':
        z=0
    if z==1:
        for i in range(n):
            # print(s[i])
            if s[i]=='-':
                # print(1)
                if i!=0 and i!=n-1:
                    # print(2)
                    if s[i+1]=='-' or s[i-1]=='-':
                        together+=1
                    else:
                        alone+=1
                else:
                    # print(3)
                    if i==0:
                        if s[i+1]=='-' or s[n-1]=='-':
                            together+=1
                        else:
                            alone+=1
                    elif i==n-1:
                        if s[i-1]=='-' or s[0]=='-':
                            together+=1
                        else:
                            alone+=1
        if alone+together>0:
            print((alone*2)+(together+1))
        else:
            print(0)
    else:
        print(n)


test_cases=int(input())
for test_case in range(test_cases):
    n = (int(input()))
    s=input()
    a=sorted(s)
    ans=0
    z=0
    count=0
    alone=0
    together=0
    if a[-1]=='<':
        z=1
    elif a[-1]=='>':
        for i in s:
            if i =='<':
                z=1
                break
    elif a[-1]=='-':
        z=0
    if z==1:
        for i in range(n):
            # print(s[i])
            if s[i]=='-':
                # print(1)
                if i!=0 and i!=n-1:
                    # print(2)
                    if s[i+1]=='-' or s[i-1]=='-':
                        together+=1
                    else:
                        alone+=1
                else:
                    # print(3)
                    if i==0:
                        if s[i+1]=='-' or s[n-1]=='-':
                            together+=1
                        else:
                            alone+=1
                    elif i==n-1:
                        if s[i-1]=='-' or s[0]=='-':
                            together+=1
                        else:
                            alone+=1
        if together>0:
            print((alone*2)+(together+1))
        else:
            print(alone*2)
    else:
        print(n)


# Problem: B. Belted Rooms
# Contest: Codeforces - Codeforces Raif Round 1 (Div. 1 + Div. 2)
# URL: https://codeforces.com/contest/1428/problem/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)

from queue import LifoQueue
for _ in range(int(input())):
	n=int(input())
	S=input()

	q=LifoQueue()

	for _ in range(n):
		if q.empty():
			q.put(S[_])
		else:
			x=q.get()
			if x+S[_]=="><" or x+S[_]=="<>":
				q.put(x)
			else:
				q.put(x)
				q.put(S[_])
	x=q.get()
	if x+S[0]=="<>" or x+S[0]=="><":
		pass
	else:
		q.put(x)

	ans=0
	while not q.empty():
		ans+=1
		q.get()
	if ans==1:
		print(0)
	else:
		print(ans)


# Problem: B. Belted Rooms
# Contest: Codeforces - Codeforces Raif Round 1 (Div. 1 + Div. 2)
# URL: https://codeforces.com/contest/1428/problem/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)

for _ in range(int(input())):
	n=int(input())
	S=input()

	X=[False for _ in range(n)]

	clo=0
	anti=0

	for i in range(n):
		if S[i]==">":
			clo+=1
		elif S[i]=="<":
			anti+=1
		else:
			X[i]=True
			X[(i+1)%n]=True

	if anti==0 or clo==0:
		print(n)
	else:
		ans=0
		for i in range(n):
			if X[i]==True:
				ans+=1
		print(ans)


# Problem: B. Belted Rooms
# Contest: Codeforces - Codeforces Raif Round 1 (Div. 1 + Div. 2)
# URL: https://codeforces.com/contest/1428/problem/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)

from queue import LifoQueue
for _ in range(int(input())):
	n=int(input())
	S=input()

	q=LifoQueue()

	for _ in range(n):
		if q.empty():
			q.put(S[_])
		else:
			x=q.get()
			if x+S[_]=="><" or x+S[_]=="<>":
				q.put(x)
			else:
				q.put(x)
				q.put(S[_])
	x=q.get()
	if x+S[0]=="<>" or x+S[0]=="><":
		q.put(x)
	else:
		q.put(x)

	ans=0
	while not q.empty():
		ans+=1
		q.get()
	if ans==1:
		print(0)
	else:
		print(ans)


# Problem: B. Belted Rooms
# Contest: Codeforces - Codeforces Raif Round 1 (Div. 1 + Div. 2)
# URL: https://codeforces.com/contest/1428/problem/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)

from queue import LifoQueue
for _ in range(int(input())):
	n=int(input())
	S=input()

	s=""
	c=0

	ans=0
	X=[False for _ in range(n)]
	for _ in range(n):
		if S[_]!="-":
			s+=S[_]
			c+=1
		else:
			X[_%n]=True
			X[(_+1)%n]=True
	if c!=0:
		if s==s[0]*c:
			print(n)
		else:
			for _ in range(n):
				if X[_]==True:
					ans+=1
			print(ans)
	else:
		print(n)


import time,math as mt,bisect,sys
from sys import stdin,stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi=3.14159265358979323846264338327950
def II(): # to take integer input
    return int(stdin.readline())
def IO(): # to take string input
    return stdin.readline()
def IP(): # to take tuple as input
    return map(int,stdin.readline().split())
def L(): # to take list as input
    return list(map(int,stdin.readline().split()))
def P(x): # to print integer,list,string etc..
    return stdout.write(str(x)+"\n")
def PI(x,y): # to print tuple separatedly
    return stdout.write(str(x)+" "+str(y)+"\n")
def lcm(a,b): # to calculate lcm
    return (a*b)//gcd(a,b)
def gcd(a,b): # to calculate gcd
    if a==0:
        return b
    elif b==0:
        return a
    if a>b:
        return gcd(a%b,b)
    else:
        return gcd(a,b%a)
def bfs(adj,v): # a schema of bfs
    visited=[False]*(v+1)
    q=deque()
    while q:
        pass
def sieve():
    li=[True]*1000001
    li[0],li[1]=False,False
    for i in range(2,len(li),1):
        if li[i]==True:
            for j in range(i*i,len(li),i):
                li[j]=False
    prime=[]
    for i in range(1000001):
        if li[i]==True:
            prime.append(i)
    return prime
def setBit(n):
    count=0
    while n!=0:
        n=n&(n-1)
        count+=1
    return count
mx=10**7
spf=[mx]*(mx+1)
def SPF():
    spf[1]=1
    for i in range(2,mx+1):
        if spf[i]==mx:
            spf[i]=i
            for j in range(i*i,mx+1,i):
                if i<spf[j]:
                    spf[j]=i
    return
def readTree(v): # to read tree
    adj=[set() for i in range(v+1)]
    for i in range(v-1):
        u1,u2=In()
        adj[u1].add(u2)
        adj[u2].add(u1)
    return adj
#####################################################################################

def solve():
    n=II()
    s=input()
    cnt0,cnt1=0,0
    for ele in s:
        if ele=='>' or ele=='-':
            cnt0+=1
        elif ele=='<' or ele=='-':
            cnt1+=1
    if cnt0>=n or cnt1>=n:
        print(n)
        return
    s=s[n-1]+s
    s=s+s[1]
    ans=0
    #print(s)
    i=1
    ans=[0]*(n)
    while i<(len(s)-1):
        if (s[i]=='-'):
            #print(i)
            ans[(i-1)%n]=1
            ans[i%n]=1
        i+=1
    #print(ans)
    print(ans.count(1))
    return

t=II()
for i in range(t):
    solve()

    #######
   #
  #
 #######   #     #  # ####   # #     #
       #  # #   #  # #   #  # # #   #
      #  ####  #  # ####   ####  # #
######  #   # #### #    # #   #   #

# ``````¶0````1¶1_```````````````````````````````````````
# ```````¶¶¶0_`_¶¶¶0011100¶¶¶¶¶¶¶001_````````````````````
# ````````¶¶¶¶¶00¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶0_````````````````
# `````1_``¶¶00¶0000000000000000000000¶¶¶¶0_`````````````
# `````_¶¶_`0¶000000000000000000000000000¶¶¶¶¶1``````````
# ```````¶¶¶00¶00000000000000000000000000000¶¶¶_`````````
# ````````_¶¶00000000000000000000¶¶00000000000¶¶`````````
# `````_0011¶¶¶¶¶000000000000¶¶00¶¶0¶¶00000000¶¶_````````
# ```````_¶¶¶¶¶¶¶00000000000¶¶¶¶0¶¶¶¶¶00000000¶¶1````````
# ``````````1¶¶¶¶¶000000¶¶0¶¶¶¶¶¶¶¶¶¶¶¶0000000¶¶¶````````
# ```````````¶¶¶0¶000¶00¶0¶¶`_____`__1¶0¶¶00¶00¶¶````````
# ```````````¶¶¶¶¶00¶00¶10¶0``_1111_`_¶¶0000¶0¶¶¶````````
# ``````````1¶¶¶¶¶00¶0¶¶_¶¶1`_¶_1_0_`1¶¶_0¶0¶¶0¶¶````````
# ````````1¶¶¶¶¶¶¶0¶¶0¶0_0¶``100111``_¶1_0¶0¶¶_1¶````````
# ```````1¶¶¶¶00¶¶¶¶¶¶¶010¶``1111111_0¶11¶¶¶¶¶_10````````
# ```````0¶¶¶¶__10¶¶¶¶¶100¶¶¶0111110¶¶¶1__¶¶¶¶`__````````
# ```````¶¶¶¶0`__0¶¶0¶¶_¶¶¶_11````_0¶¶0`_1¶¶¶¶```````````
# ```````¶¶¶00`__0¶¶_00`_0_``````````1_``¶0¶¶_```````````
# ``````1¶1``¶¶``1¶¶_11``````````````````¶`¶¶````````````
# ``````1_``¶0_¶1`0¶_`_``````````_``````1_`¶1````````````
# ``````````_`1¶00¶¶_````_````__`1`````__`_¶`````````````
# ````````````¶1`0¶¶_`````````_11_`````_``_``````````````
# `````````¶¶¶¶000¶¶_1```````_____```_1``````````````````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶0_``````_````_1111__``````````````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶01_`````_11____1111_```````````
# `````````¶¶0¶0¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶1101_______11¶_```````````
# ``````_¶¶¶0000000¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶0¶0¶¶¶1````````````
# `````0¶¶0000000¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶1`````````````
# ````0¶0000000¶¶0_````_011_10¶110¶01_1¶¶¶0````_100¶001_`
# ```1¶0000000¶0_``__`````````_`````````0¶_``_00¶¶010¶001
# ```¶¶00000¶¶1``_01``_11____``1_``_`````¶¶0100¶1```_00¶1
# ``1¶¶00000¶_``_¶_`_101_``_`__````__````_0000001100¶¶¶0`
# ``¶¶¶0000¶1_`_¶``__0_``````_1````_1_````1¶¶¶0¶¶¶¶¶¶0```
# `_¶¶¶¶00¶0___01_10¶_``__````1`````11___`1¶¶¶01_````````
# `1¶¶¶¶¶0¶0`__01¶¶¶0````1_```11``___1_1__11¶000`````````
# `1¶¶¶¶¶¶¶1_1_01__`01```_1```_1__1_11___1_``00¶1````````
# ``¶¶¶¶¶¶¶0`__10__000````1____1____1___1_```10¶0_```````
# ``0¶¶¶¶¶¶¶1___0000000```11___1__`_0111_```000¶01```````
# ```¶¶¶00000¶¶¶¶¶¶¶¶¶01___1___00_1¶¶¶`_``1¶¶10¶¶0```````
# ```1010000¶000¶¶0100_11__1011000¶¶0¶1_10¶¶¶_0¶¶00``````
# 10¶000000000¶0________0¶000000¶¶0000¶¶¶¶000_0¶0¶00`````
# ¶¶¶¶¶¶0000¶¶¶¶_`___`_0¶¶¶¶¶¶¶00000000000000_0¶00¶01````
# ¶¶¶¶¶0¶¶¶¶¶¶¶¶¶_``_1¶¶¶00000000000000000000_0¶000¶01```
# 1__```1¶¶¶¶¶¶¶¶¶00¶¶¶¶00000000000000000000¶_0¶0000¶0_``
# ```````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶00000000000000000000010¶00000¶¶_`
# ```````0¶¶¶¶¶¶¶¶¶¶¶¶¶¶00000000000000000000¶10¶¶0¶¶¶¶¶0`
# ````````¶¶¶¶¶¶¶¶¶¶0¶¶¶00000000000000000000010¶¶¶0011```
# ````````1¶¶¶¶¶¶¶¶¶¶0¶¶¶0000000000000000000¶100__1_`````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶000000000000000000¶11``_1``````
# `````````1¶¶¶¶¶¶¶¶¶¶¶0¶¶¶00000000000000000¶11___1_`````
# ``````````¶¶¶¶¶¶0¶0¶¶¶¶¶¶¶0000000000000000¶11__``1_````
# ``````````¶¶¶¶¶¶¶0¶¶¶0¶¶¶¶¶000000000000000¶1__````__```
# ``````````¶¶¶¶¶¶¶¶0¶¶¶¶¶¶¶¶¶0000000000000000__`````11``
# `````````_¶¶¶¶¶¶¶¶¶000¶¶¶¶¶¶¶¶000000000000011_``_1¶¶¶0`
# `````````_¶¶¶¶¶¶0¶¶000000¶¶¶¶¶¶¶000000000000100¶¶¶¶0_`_
# `````````1¶¶¶¶¶0¶¶¶000000000¶¶¶¶¶¶000000000¶00¶¶01`````
# `````````¶¶¶¶¶0¶0¶¶¶0000000000000¶0¶00000000011_``````_
# ````````1¶¶0¶¶¶0¶¶¶¶¶¶¶000000000000000000000¶11___11111
# ````````¶¶¶¶0¶¶¶¶¶00¶¶¶¶¶¶000000000000000000¶011111111_
# ```````_¶¶¶¶¶¶¶¶¶0000000¶0¶00000000000000000¶01_1111111
# ```````0¶¶¶¶¶¶¶¶¶000000000000000000000000000¶01___`````
# ```````¶¶¶¶¶¶0¶¶¶000000000000000000000000000¶01___1````
# ``````_¶¶¶¶¶¶¶¶¶00000000000000000000000000000011_111```
# ``````0¶¶0¶¶¶0¶¶0000000000000000000000000000¶01`1_11_``
# ``````¶¶¶¶¶¶0¶¶¶0000000000000000000000000000001`_0_11_`
# ``````¶¶¶¶¶¶¶¶¶00000000000000000000000000000¶01``_0_11`
# ``````¶¶¶¶0¶¶¶¶00000000000000000000000000000001```_1_11


import time,math as mt,bisect,sys
from sys import stdin,stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi=3.14159265358979323846264338327950
def II(): # to take integer input
    return int(stdin.readline())
def IO(): # to take string input
    return stdin.readline()
def IP(): # to take tuple as input
    return map(int,stdin.readline().split())
def L(): # to take list as input
    return list(map(int,stdin.readline().split()))
def P(x): # to print integer,list,string etc..
    return stdout.write(str(x)+"\n")
def PI(x,y): # to print tuple separatedly
    return stdout.write(str(x)+" "+str(y)+"\n")
def lcm(a,b): # to calculate lcm
    return (a*b)//gcd(a,b)
def gcd(a,b): # to calculate gcd
    if a==0:
        return b
    elif b==0:
        return a
    if a>b:
        return gcd(a%b,b)
    else:
        return gcd(a,b%a)
def bfs(adj,v): # a schema of bfs
    visited=[False]*(v+1)
    q=deque()
    while q:
        pass
def sieve():
    li=[True]*1000001
    li[0],li[1]=False,False
    for i in range(2,len(li),1):
        if li[i]==True:
            for j in range(i*i,len(li),i):
                li[j]=False
    prime=[]
    for i in range(1000001):
        if li[i]==True:
            prime.append(i)
    return prime
def setBit(n):
    count=0
    while n!=0:
        n=n&(n-1)
        count+=1
    return count
mx=10**7
spf=[mx]*(mx+1)
def SPF():
    spf[1]=1
    for i in range(2,mx+1):
        if spf[i]==mx:
            spf[i]=i
            for j in range(i*i,mx+1,i):
                if i<spf[j]:
                    spf[j]=i
    return
def readTree(v): # to read tree
    adj=[set() for i in range(v+1)]
    for i in range(v-1):
        u1,u2=In()
        adj[u1].add(u2)
        adj[u2].add(u1)
    return adj
#####################################################################################

def solve():
    n=II()
    s=input()
    cnt0,cnt1=0,0
    for ele in s:
        if ele=='>' or ele=='-':
            cnt0+=1
        elif ele=='<' or ele=='-':
            cnt1+=1
    if cnt0>=n or cnt1>=n:
        print(n)
        return
    i=0
    ans=[0]*(n)
    while i<n:
        if (s[i]=='-'):
            #print(i)
            ans[i%n]=1
            ans[(i+1)%n]=1
        i+=1
    #print(ans)
    print(ans.count(1))
    return

t=II()
for i in range(t):
    solve()

    #######
   #
  #
 #######   #     #  # ####   # #     #
       #  # #   #  # #   #  # # #   #
      #  ####  #  # ####   ####  # #
######  #   # #### #    # #   #   #

# ``````¶0````1¶1_```````````````````````````````````````
# ```````¶¶¶0_`_¶¶¶0011100¶¶¶¶¶¶¶001_````````````````````
# ````````¶¶¶¶¶00¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶0_````````````````
# `````1_``¶¶00¶0000000000000000000000¶¶¶¶0_`````````````
# `````_¶¶_`0¶000000000000000000000000000¶¶¶¶¶1``````````
# ```````¶¶¶00¶00000000000000000000000000000¶¶¶_`````````
# ````````_¶¶00000000000000000000¶¶00000000000¶¶`````````
# `````_0011¶¶¶¶¶000000000000¶¶00¶¶0¶¶00000000¶¶_````````
# ```````_¶¶¶¶¶¶¶00000000000¶¶¶¶0¶¶¶¶¶00000000¶¶1````````
# ``````````1¶¶¶¶¶000000¶¶0¶¶¶¶¶¶¶¶¶¶¶¶0000000¶¶¶````````
# ```````````¶¶¶0¶000¶00¶0¶¶`_____`__1¶0¶¶00¶00¶¶````````
# ```````````¶¶¶¶¶00¶00¶10¶0``_1111_`_¶¶0000¶0¶¶¶````````
# ``````````1¶¶¶¶¶00¶0¶¶_¶¶1`_¶_1_0_`1¶¶_0¶0¶¶0¶¶````````
# ````````1¶¶¶¶¶¶¶0¶¶0¶0_0¶``100111``_¶1_0¶0¶¶_1¶````````
# ```````1¶¶¶¶00¶¶¶¶¶¶¶010¶``1111111_0¶11¶¶¶¶¶_10````````
# ```````0¶¶¶¶__10¶¶¶¶¶100¶¶¶0111110¶¶¶1__¶¶¶¶`__````````
# ```````¶¶¶¶0`__0¶¶0¶¶_¶¶¶_11````_0¶¶0`_1¶¶¶¶```````````
# ```````¶¶¶00`__0¶¶_00`_0_``````````1_``¶0¶¶_```````````
# ``````1¶1``¶¶``1¶¶_11``````````````````¶`¶¶````````````
# ``````1_``¶0_¶1`0¶_`_``````````_``````1_`¶1````````````
# ``````````_`1¶00¶¶_````_````__`1`````__`_¶`````````````
# ````````````¶1`0¶¶_`````````_11_`````_``_``````````````
# `````````¶¶¶¶000¶¶_1```````_____```_1``````````````````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶0_``````_````_1111__``````````````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶01_`````_11____1111_```````````
# `````````¶¶0¶0¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶1101_______11¶_```````````
# ``````_¶¶¶0000000¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶0¶0¶¶¶1````````````
# `````0¶¶0000000¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶1`````````````
# ````0¶0000000¶¶0_````_011_10¶110¶01_1¶¶¶0````_100¶001_`
# ```1¶0000000¶0_``__`````````_`````````0¶_``_00¶¶010¶001
# ```¶¶00000¶¶1``_01``_11____``1_``_`````¶¶0100¶1```_00¶1
# ``1¶¶00000¶_``_¶_`_101_``_`__````__````_0000001100¶¶¶0`
# ``¶¶¶0000¶1_`_¶``__0_``````_1````_1_````1¶¶¶0¶¶¶¶¶¶0```
# `_¶¶¶¶00¶0___01_10¶_``__````1`````11___`1¶¶¶01_````````
# `1¶¶¶¶¶0¶0`__01¶¶¶0````1_```11``___1_1__11¶000`````````
# `1¶¶¶¶¶¶¶1_1_01__`01```_1```_1__1_11___1_``00¶1````````
# ``¶¶¶¶¶¶¶0`__10__000````1____1____1___1_```10¶0_```````
# ``0¶¶¶¶¶¶¶1___0000000```11___1__`_0111_```000¶01```````
# ```¶¶¶00000¶¶¶¶¶¶¶¶¶01___1___00_1¶¶¶`_``1¶¶10¶¶0```````
# ```1010000¶000¶¶0100_11__1011000¶¶0¶1_10¶¶¶_0¶¶00``````
# 10¶000000000¶0________0¶000000¶¶0000¶¶¶¶000_0¶0¶00`````
# ¶¶¶¶¶¶0000¶¶¶¶_`___`_0¶¶¶¶¶¶¶00000000000000_0¶00¶01````
# ¶¶¶¶¶0¶¶¶¶¶¶¶¶¶_``_1¶¶¶00000000000000000000_0¶000¶01```
# 1__```1¶¶¶¶¶¶¶¶¶00¶¶¶¶00000000000000000000¶_0¶0000¶0_``
# ```````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶00000000000000000000010¶00000¶¶_`
# ```````0¶¶¶¶¶¶¶¶¶¶¶¶¶¶00000000000000000000¶10¶¶0¶¶¶¶¶0`
# ````````¶¶¶¶¶¶¶¶¶¶0¶¶¶00000000000000000000010¶¶¶0011```
# ````````1¶¶¶¶¶¶¶¶¶¶0¶¶¶0000000000000000000¶100__1_`````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶000000000000000000¶11``_1``````
# `````````1¶¶¶¶¶¶¶¶¶¶¶0¶¶¶00000000000000000¶11___1_`````
# ``````````¶¶¶¶¶¶0¶0¶¶¶¶¶¶¶0000000000000000¶11__``1_````
# ``````````¶¶¶¶¶¶¶0¶¶¶0¶¶¶¶¶000000000000000¶1__````__```
# ``````````¶¶¶¶¶¶¶¶0¶¶¶¶¶¶¶¶¶0000000000000000__`````11``
# `````````_¶¶¶¶¶¶¶¶¶000¶¶¶¶¶¶¶¶000000000000011_``_1¶¶¶0`
# `````````_¶¶¶¶¶¶0¶¶000000¶¶¶¶¶¶¶000000000000100¶¶¶¶0_`_
# `````````1¶¶¶¶¶0¶¶¶000000000¶¶¶¶¶¶000000000¶00¶¶01`````
# `````````¶¶¶¶¶0¶0¶¶¶0000000000000¶0¶00000000011_``````_
# ````````1¶¶0¶¶¶0¶¶¶¶¶¶¶000000000000000000000¶11___11111
# ````````¶¶¶¶0¶¶¶¶¶00¶¶¶¶¶¶000000000000000000¶011111111_
# ```````_¶¶¶¶¶¶¶¶¶0000000¶0¶00000000000000000¶01_1111111
# ```````0¶¶¶¶¶¶¶¶¶000000000000000000000000000¶01___`````
# ```````¶¶¶¶¶¶0¶¶¶000000000000000000000000000¶01___1````
# ``````_¶¶¶¶¶¶¶¶¶00000000000000000000000000000011_111```
# ``````0¶¶0¶¶¶0¶¶0000000000000000000000000000¶01`1_11_``
# ``````¶¶¶¶¶¶0¶¶¶0000000000000000000000000000001`_0_11_`
# ``````¶¶¶¶¶¶¶¶¶00000000000000000000000000000¶01``_0_11`
# ``````¶¶¶¶0¶¶¶¶00000000000000000000000000000001```_1_11


import time,math as mt,bisect,sys
from sys import stdin,stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi=3.14159265358979323846264338327950
def II(): # to take integer input
    return int(stdin.readline())
def IO(): # to take string input
    return stdin.readline()
def IP(): # to take tuple as input
    return map(int,stdin.readline().split())
def L(): # to take list as input
    return list(map(int,stdin.readline().split()))
def P(x): # to print integer,list,string etc..
    return stdout.write(str(x)+"\n")
def PI(x,y): # to print tuple separatedly
    return stdout.write(str(x)+" "+str(y)+"\n")
def lcm(a,b): # to calculate lcm
    return (a*b)//gcd(a,b)
def gcd(a,b): # to calculate gcd
    if a==0:
        return b
    elif b==0:
        return a
    if a>b:
        return gcd(a%b,b)
    else:
        return gcd(a,b%a)
def bfs(adj,v): # a schema of bfs
    visited=[False]*(v+1)
    q=deque()
    while q:
        pass
def sieve():
    li=[True]*1000001
    li[0],li[1]=False,False
    for i in range(2,len(li),1):
        if li[i]==True:
            for j in range(i*i,len(li),i):
                li[j]=False
    prime=[]
    for i in range(1000001):
        if li[i]==True:
            prime.append(i)
    return prime
def setBit(n):
    count=0
    while n!=0:
        n=n&(n-1)
        count+=1
    return count
mx=10**7
spf=[mx]*(mx+1)
def SPF():
    spf[1]=1
    for i in range(2,mx+1):
        if spf[i]==mx:
            spf[i]=i
            for j in range(i*i,mx+1,i):
                if i<spf[j]:
                    spf[j]=i
    return
def readTree(v): # to read tree
    adj=[set() for i in range(v+1)]
    for i in range(v-1):
        u1,u2=In()
        adj[u1].add(u2)
        adj[u2].add(u1)
    return adj
#####################################################################################

def solve():
    n=II()
    s=input()
    cnt0,cnt1=0,0
    for ele in s:
        if ele=='>' or ele=='-':
            cnt0+=1
        if ele=='<' or ele=='-':
            cnt1+=1
    if cnt0>=n or cnt1>=n:
        print(n)
        return
    i=0
    ans=[0]*(n)
    while i<n:
        if (s[i]=='-'):
            #print(i)
            ans[i%n]=1
            ans[(i+1)%n]=1
        i+=1
    #print(ans)
    print(ans.count(1))
    return

t=II()
for i in range(t):
    solve()

    #######
   #
  #
 #######   #     #  # ####   # #     #
       #  # #   #  # #   #  # # #   #
      #  ####  #  # ####   ####  # #
######  #   # #### #    # #   #   #

# ``````¶0````1¶1_```````````````````````````````````````
# ```````¶¶¶0_`_¶¶¶0011100¶¶¶¶¶¶¶001_````````````````````
# ````````¶¶¶¶¶00¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶0_````````````````
# `````1_``¶¶00¶0000000000000000000000¶¶¶¶0_`````````````
# `````_¶¶_`0¶000000000000000000000000000¶¶¶¶¶1``````````
# ```````¶¶¶00¶00000000000000000000000000000¶¶¶_`````````
# ````````_¶¶00000000000000000000¶¶00000000000¶¶`````````
# `````_0011¶¶¶¶¶000000000000¶¶00¶¶0¶¶00000000¶¶_````````
# ```````_¶¶¶¶¶¶¶00000000000¶¶¶¶0¶¶¶¶¶00000000¶¶1````````
# ``````````1¶¶¶¶¶000000¶¶0¶¶¶¶¶¶¶¶¶¶¶¶0000000¶¶¶````````
# ```````````¶¶¶0¶000¶00¶0¶¶`_____`__1¶0¶¶00¶00¶¶````````
# ```````````¶¶¶¶¶00¶00¶10¶0``_1111_`_¶¶0000¶0¶¶¶````````
# ``````````1¶¶¶¶¶00¶0¶¶_¶¶1`_¶_1_0_`1¶¶_0¶0¶¶0¶¶````````
# ````````1¶¶¶¶¶¶¶0¶¶0¶0_0¶``100111``_¶1_0¶0¶¶_1¶````````
# ```````1¶¶¶¶00¶¶¶¶¶¶¶010¶``1111111_0¶11¶¶¶¶¶_10````````
# ```````0¶¶¶¶__10¶¶¶¶¶100¶¶¶0111110¶¶¶1__¶¶¶¶`__````````
# ```````¶¶¶¶0`__0¶¶0¶¶_¶¶¶_11````_0¶¶0`_1¶¶¶¶```````````
# ```````¶¶¶00`__0¶¶_00`_0_``````````1_``¶0¶¶_```````````
# ``````1¶1``¶¶``1¶¶_11``````````````````¶`¶¶````````````
# ``````1_``¶0_¶1`0¶_`_``````````_``````1_`¶1````````````
# ``````````_`1¶00¶¶_````_````__`1`````__`_¶`````````````
# ````````````¶1`0¶¶_`````````_11_`````_``_``````````````
# `````````¶¶¶¶000¶¶_1```````_____```_1``````````````````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶0_``````_````_1111__``````````````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶01_`````_11____1111_```````````
# `````````¶¶0¶0¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶1101_______11¶_```````````
# ``````_¶¶¶0000000¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶0¶0¶¶¶1````````````
# `````0¶¶0000000¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶1`````````````
# ````0¶0000000¶¶0_````_011_10¶110¶01_1¶¶¶0````_100¶001_`
# ```1¶0000000¶0_``__`````````_`````````0¶_``_00¶¶010¶001
# ```¶¶00000¶¶1``_01``_11____``1_``_`````¶¶0100¶1```_00¶1
# ``1¶¶00000¶_``_¶_`_101_``_`__````__````_0000001100¶¶¶0`
# ``¶¶¶0000¶1_`_¶``__0_``````_1````_1_````1¶¶¶0¶¶¶¶¶¶0```
# `_¶¶¶¶00¶0___01_10¶_``__````1`````11___`1¶¶¶01_````````
# `1¶¶¶¶¶0¶0`__01¶¶¶0````1_```11``___1_1__11¶000`````````
# `1¶¶¶¶¶¶¶1_1_01__`01```_1```_1__1_11___1_``00¶1````````
# ``¶¶¶¶¶¶¶0`__10__000````1____1____1___1_```10¶0_```````
# ``0¶¶¶¶¶¶¶1___0000000```11___1__`_0111_```000¶01```````
# ```¶¶¶00000¶¶¶¶¶¶¶¶¶01___1___00_1¶¶¶`_``1¶¶10¶¶0```````
# ```1010000¶000¶¶0100_11__1011000¶¶0¶1_10¶¶¶_0¶¶00``````
# 10¶000000000¶0________0¶000000¶¶0000¶¶¶¶000_0¶0¶00`````
# ¶¶¶¶¶¶0000¶¶¶¶_`___`_0¶¶¶¶¶¶¶00000000000000_0¶00¶01````
# ¶¶¶¶¶0¶¶¶¶¶¶¶¶¶_``_1¶¶¶00000000000000000000_0¶000¶01```
# 1__```1¶¶¶¶¶¶¶¶¶00¶¶¶¶00000000000000000000¶_0¶0000¶0_``
# ```````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶00000000000000000000010¶00000¶¶_`
# ```````0¶¶¶¶¶¶¶¶¶¶¶¶¶¶00000000000000000000¶10¶¶0¶¶¶¶¶0`
# ````````¶¶¶¶¶¶¶¶¶¶0¶¶¶00000000000000000000010¶¶¶0011```
# ````````1¶¶¶¶¶¶¶¶¶¶0¶¶¶0000000000000000000¶100__1_`````
# `````````¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶000000000000000000¶11``_1``````
# `````````1¶¶¶¶¶¶¶¶¶¶¶0¶¶¶00000000000000000¶11___1_`````
# ``````````¶¶¶¶¶¶0¶0¶¶¶¶¶¶¶0000000000000000¶11__``1_````
# ``````````¶¶¶¶¶¶¶0¶¶¶0¶¶¶¶¶000000000000000¶1__````__```
# ``````````¶¶¶¶¶¶¶¶0¶¶¶¶¶¶¶¶¶0000000000000000__`````11``
# `````````_¶¶¶¶¶¶¶¶¶000¶¶¶¶¶¶¶¶000000000000011_``_1¶¶¶0`
# `````````_¶¶¶¶¶¶0¶¶000000¶¶¶¶¶¶¶000000000000100¶¶¶¶0_`_
# `````````1¶¶¶¶¶0¶¶¶000000000¶¶¶¶¶¶000000000¶00¶¶01`````
# `````````¶¶¶¶¶0¶0¶¶¶0000000000000¶0¶00000000011_``````_
# ````````1¶¶0¶¶¶0¶¶¶¶¶¶¶000000000000000000000¶11___11111
# ````````¶¶¶¶0¶¶¶¶¶00¶¶¶¶¶¶000000000000000000¶011111111_
# ```````_¶¶¶¶¶¶¶¶¶0000000¶0¶00000000000000000¶01_1111111
# ```````0¶¶¶¶¶¶¶¶¶000000000000000000000000000¶01___`````
# ```````¶¶¶¶¶¶0¶¶¶000000000000000000000000000¶01___1````
# ``````_¶¶¶¶¶¶¶¶¶00000000000000000000000000000011_111```
# ``````0¶¶0¶¶¶0¶¶0000000000000000000000000000¶01`1_11_``
# ``````¶¶¶¶¶¶0¶¶¶0000000000000000000000000000001`_0_11_`
# ``````¶¶¶¶¶¶¶¶¶00000000000000000000000000000¶01``_0_11`
# ``````¶¶¶¶0¶¶¶¶00000000000000000000000000000001```_1_11


def dfs(graph,node,visited):
	#print(node)

	if node not in visited:
		visited.append(node)
		for n in graph[node]:
			dfs(graph,n,visited)
	else:
		try:
			if node==visited[0]:
				visited.append(node)
				return visited
		except:
			return visited
	return visited

from collections import defaultdict

cases=int(input())
for _ in range(cases):
	d=defaultdict(list)
	n=int(input())
	s=input()

	for i in range(len(s)):
		if s[i]=='-':
			d[i].append((i+1)%n)
			d[(i+1)%n].append(i)
		elif s[i]=='>':
			d[i].append((i+1)%n)
		elif s[i]=='<':
			d[(i+1)%n].append(i)
	count=0
	for i in range(len(s)):
		if i not in d.keys():
			continue
		visited=dfs(d,i,[])
		#print(visited)

		if i in visited and len(visited)>1 and visited.count(i)>=2:
			count+=1

	print(count)


def dfs(graph,node,visited):
	#print(node)

	if node not in visited:
		visited.append(node)
		for n in graph[node]:
			dfs(graph,n,visited)
	else:
		visited.append(node)

	return visited

from collections import defaultdict

cases=int(input())
for _ in range(cases):
	d=defaultdict(list)
	n=int(input())
	s=input()

	for i in range(len(s)):
		if s[i]=='-':
			d[i].append((i+1)%n)
			d[(i+1)%n].append(i)
		elif s[i]=='>':
			d[i].append((i+1)%n)
		elif s[i]=='<':
			d[(i+1)%n].append(i)
	count=0
	for i in range(len(s)):
		if i not in d.keys():
			continue
		visited=dfs(d,i,[])
		#print(visited)

		if i in visited and len(visited)>1 and visited.count(i)>=2:
			count+=1

	print(count)


from collections import defaultdict

cases=int(input())
for _ in range(cases):
	d=defaultdict(list)
	n=int(input())
	s=input()
	for i in range(len(s)):
		if s[i]=='-':
			d[i].append((i+1)%n)
			d[(i+1)%n].append(i)
		elif s[i]=='>':
			d[i].append((i+1)%n)
		elif s[i]=='<':
			d[(i+1)%n].append(i)

	if len(d.keys())==1:
		print(0)
	else:
		print(len(d.keys()))


def dfs(graph,node,visited):
	#print(node)

	if node not in visited:
		visited.append(node)
		for n in graph[node]:
			if n in graph.keys():
				dfs(graph,n,visited)
	else:
		visited.append(node)
		return visited

	return visited

from collections import defaultdict

cases=int(input())
for _ in range(cases):
	d=defaultdict(list)
	n=int(input())
	s=input()

	for i in range(len(s)):
		if s[i]=='-':
			d[i].append((i+1)%n)
			d[(i+1)%n].append(i)
		elif s[i]=='>':
			d[i].append((i+1)%n)
		elif s[i]=='<':
			d[(i+1)%n].append(i)
	count=0
	for i in range(len(s)):
		if i not in d.keys():
			continue
		visited=dfs(d,i,[])
		#print(visited)

		if i in visited and len(visited)>1 and visited.count(i)>=2:
			count+=1

	print(count)


def dfs(graph,node,visited):
	init_node=node
	if node not in visited:
		visited.append(node)
		for neighbours in graph[node]:
			dfs(graph,neighbours,visited)

	else:
		visited.append(node)
		return visited

	return visited

from collections import defaultdict

cases=int(input())
for _ in range(cases):
	d=defaultdict(list)
	n=int(input())
	s=input()

	for i in range(len(s)):
		if s[i]=='-':
			d[i].append((i+1)%n)
			d[(i+1)%n].append(i)
		elif s[i]=='>':
			d[i].append((i+1)%n)
		elif s[i]=='<':
			d[(i+1)%n].append(i)
	count=0
	r=list(d.keys())
	for i in range(len(r)):
		visited=dfs(d,r[i],[])
		#print(visited)

		if len(visited)>1 and visited.count(r[i])>=2:
			count+=1

	print(count)


def dfs(graph,node,visited):
	#print(node)

	if node not in visited:
		visited.append(node)
		for n in graph[node]:
			dfs(graph,n,visited)
	else:
		if node==visited[0]:
			visited.append(node)
			return visited
	return visited

from collections import defaultdict

cases=int(input())
for _ in range(cases):
	d=defaultdict(list)
	n=int(input())
	s=input()

	for i in range(len(s)):
		if s[i]=='-':
			d[i].append((i+1)%n)
			d[(i+1)%n].append(i)
		elif s[i]=='>':
			d[i].append((i+1)%n)
		elif s[i]=='<':
			d[(i+1)%n].append(i)
	count=0
	for i in range(len(s)):
		if i not in d.keys():
			continue
		visited=dfs(d,i,[])
		#print(visited)

		if i in visited and len(visited)>1 and visited.count(i)>=2:
			count+=1

	print(count)


cases=int(input())
for _ in  range(cases):
	n=int(input())
	s=input()
	clock=False
	cclock=False
	for c in s:
		if c=='>':
			clock=True
		if c=='<':
			cclock=True
	if clock and cclock:
		s+=s[0]
		tot=0
		for i in range(n):
			if s[i]=='-' or s[(i+1)%n]=='-':
				tot+=1
		print(tot)
	else:
		print(n)


def dfs(graph,node,visited):
	#print(node)

	if node not in visited:
		visited.append(node)
		for n in graph[node]:
			dfs(graph,n,visited)
	else:
		visited.append(node)
		return visited

	return visited

from collections import defaultdict

cases=int(input())
for _ in range(cases):
	d=defaultdict(list)
	n=int(input())
	s=input()

	for i in range(len(s)):
		if s[i]=='-':
			d[i].append((i+1)%n)
			d[(i+1)%n].append(i)
		elif s[i]=='>':
			d[i].append((i+1)%n)
		elif s[i]=='<':
			d[(i+1)%n].append(i)
	count=0
	for i in range(len(s)):
		if i not in d.keys():
			continue
		visited=dfs(d,i,[])
		#print(visited)

		if i in visited and len(visited)>1 and visited.count(i)>=2:
			count+=1

	print(count)


from sys import stdin, stdout
ans = []
def main():
    n = int(stdin.readline())
    arr =list(stdin.readline())[:-1]
    print(arr)
    count = 0
    hasCW = False
    hasCCW = False
    for c in arr:
        if c == '<':
            hasCW = True
        if c == '>':
            hasCCW = True

    if hasCW and hasCCW:
        arr += arr[0]
        for i in range(n):
            if arr[i] == '-' or arr[i+1] == '-':
                count += 1
        ans.append(str(count))
        return
    else:
        ans.append(str(n))

    # ans.append(str(count))
if __name__ =='__main__':
    for _ in range(int(input())):
        main()
    stdout.write('\n'.join(ans))


from sys import stdin, stdout
ans = []
def main():
    n = int(stdin.readline())
    arr =list(stdin.readline())[:-1]
    # print(arr)
    count = 0
    hasCW = False
    hasCCW = False
    for c in arr:
        if c == '<':
            hasCW = True
        if c == '>':
            hasCCW = True

    if hasCW and hasCCW:
        arr += arr[0]
        for i in range(n):
            if arr[i] == '-' or arr[i+1] == '-':
                count += 1
        ans.append(str(count))
        return
    else:
        ans.append(str(n))

    # ans.append(str(count))
if __name__ =='__main__':
    for _ in range(int(input())):
        main()
    stdout.write('\n'.join(ans))


from sys import stdin, stdout
ans = []
def main():
    n = int(stdin.readline())
    arr = [map(int,stdin.readline().split())]
    count = 0
    hasCW = False
    fhasCCW = False
    for c in arr:
        if c == '<':
            hasCW = True
        if c == '>':
            hasCCW = True

    if hasCW and hasCCW:
        arr += arr[0]
        for i in range(n):
            if arr[i] == '-' or arr[i+1] == '-':
                count += 1
        ans.append(str(count))
    else:
        ans.append(str(n))

    ans.append(str(count))
if __name__ =='__main__':
    for _ in range(int(input())):
        main()
    stdout.write('\n'.join(ans))


t = input()
t = int(t)

def solve(n, s):

    cnt1 = 0
    cnt2 = 0

    for i in range(n):
        if s[i]=='<':
            cnt1+=1
        elif s[i]=='>':
            cnt2+=1

    if cnt1==0 or cnt2==0:
        print(n)
        return

    s_hat = s+s[0]
    cnt = 0

    for i in range(n):
        if s_hat[i]!='-' and s_hat[i+1]!='-':
            cnt+=1
    print(n-cnt)

for i in range(t):
    n = input()
    n = int(n)
    s = input()

    solve(n, s)


t = input()
t = int(t)

def solve(n, s):

    setS= set(s)

    cnt1 = 0
    cnt2 = 0

    for i in range(n):
        if s[i]=='<':
            cnt1+=1
        elif s[i]=='>':
            cnt2+=1

    if cnt1==0 or cnt2==0:
        print(n)
        return

    cnt = 0
    for i in range(n):
        if s[i]=='-':
            cnt+=1

    if cnt==0:
        print(cnt)
    else :
        print(cnt+1)
    return

for i in range(t):
    n = input()
    n = int(n)
    s = input()

    solve(n, s)


t = input()
t = int(t)

def solve(n, s):

    cnt1 = 0
    cnt2 = 0

    for i in range(n):
        if s[i]=='<':
            cnt1+=1
        elif s[i]=='>':
            cnt2+=1

    if cnt1==0 or cnt2==0:
        print(n)
        return

    s_hat = s+s[0]
    cnt = 0

    for i in range(n+1):
        if s_hat[i]!='-' and s_hat[i+1]!='-':
            cnt+=1
    print(n-cnt)

for i in range(t):
    n = input()
    n = int(n)
    s = input()

    solve(n, s)


'''
Name : Jaymeet Mehta
codeforces id :mj_13
Problem :
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    n=int(stdin.readline())
    s = stdin.readline().strip()
    ch=1
    ans=n
    i=0
    if n==2:
        if (s[0]==">" and s[1]=="<") or (s[0]=="<" and s[1]==">"):
            print(0)
            continue
        else:
            print(2)
            continue

    while(i<n-1):
        if s[i]=="-":
            ch=1
            i+=1
            continue
        if not ch:
            i+=1
            ans-=1
            continue
        if (s[i]==">" and s[i+1]=="<") or (s[i]=="<" and s[i+1]==">"):
            ch=0
            ans-=1
            i+=2
            continue
        i+=1
    print(ans)


'''
Name : Jaymeet Mehta
codeforces id :mj_13
Problem :
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    n=int(stdin.readline())
    s = stdin.readline().strip()
    c1,c2,c3=s.count('>'),s.count('<'),s.count('-')
    if c1==0 or c2==0:
        print(n)
        continue
    if c3==0:
        print(0)
        continue
    ans,cnt=0,1
    ch=0
    start=0
    for i in range(n):
        if s[i]!='-':
            start=i
            break
    i=0
    ch=0
    while(i<n):
        if s[start]!="-":
            if ch: ans+=cnt
            cnt=1
            ch=0
        else:
            cnt+=1
            ch=1
        start=(start+1)%n
        i+=1
    if cnt!=1:
        ans+=cnt
    print(ans)


'''
Name : Jaymeet Mehta
codeforces id :mj_13
Problem :
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    n=int(stdin.readline())
    s = stdin.readline().strip()
    ch=1
    ans=n
    i=0
    if (s[0]==">" and s[-1]=="<") or (s[0]=="<" and s[-1]==">"):
        ans-=1
        ch=0
    while(i<n):
        if s[i]=="-":
            ch=1
            i+=1
            continue
        if not ch:
            i+=1
            ans-=1
            continue
        if i<n-1:
            if (s[i]==">" and s[i+1]=="<") or (s[i]=="<" and s[i+1]==">"):
                ch=0
                ans-=1
                i+=2
                continue
        i+=1
    print(ans)


'''
Name : Jaymeet Mehta
codeforces id :mj_13
Problem :
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    n=int(stdin.readline())
    s = stdin.readline().strip()
    c1,c2,c3=s.count('>'),s.count('<'),s.count('-')
    if c1==0 or c2==0:
        print(n)
        continue
    if c3==0:
        print(0)
        continue
    ans,cnt=0,1
    ch=0
    start=0
    for i in range(n):
        if s[i]!='-':
            start=i
            break
    i=0
    ch=0
    while(i<n):
        if s[start]!="-":
            if ch: ans+=cnt
            cnt=1
        else:
            cnt+=1
            ch=1
        start=(start+1)%n
        i+=1
    if cnt!=1:
        ans+=cnt
    print(ans)


'''
Name : Jaymeet Mehta
codeforces id :mj_13
Problem :
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    n=int(stdin.readline())
    s = stdin.readline().strip()
    ch=1
    ans=n
    i=0
    if (s[0]==">" and s[-1]=="<") or (s[0]=="<" and s[-1]==">"):
        # ans-=1
        ch=0
    while(i<n):
        if s[i]=="-":
            ch=1
            i+=1
            continue
        if not ch:
            i+=1
            ans-=1
            continue
        if i<n-1:
            if (s[i]==">" and s[i+1]=="<") or (s[i]=="<" and s[i+1]==">"):
                ch=0
                ans-=1
                i+=2
                continue
        i+=1
    print(ans)


'''
Name : Jaymeet Mehta
codeforces id :mj_13
Problem :
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    n=int(stdin.readline())
    s = stdin.readline().strip()
    c1,c2,c3=s.count('>'),s.count('<'),s.count('-')
    if c1==0 or c2==0:
        print(n)
        continue
    if c3==0:
        print(0)
        continue
    ans,cnt=0,1
    ch=0
    for i in s:
        if i!="-":
            if ch : ans+=cnt
            cnt=1
        else:
            cnt+=1
            ch=1
    print(ans)


'''
Name : Jaymeet Mehta
codeforces id :mj_13
Problem :
'''
from sys import stdin,stdout
test=int(stdin.readline())
for _ in range(test):
    n=int(stdin.readline())
    s = stdin.readline().strip()
    ch=1
    ans=n
    i=0
    if (s[0]==">" and s[-1]=="<") or (s[0]=="<" and s[-1]==">"):
        ans-=1
    while(i<n):
        if s[i]=="-":
            ch=1
            i+=1
            continue
        if not ch:
            i+=1
            ans-=1
            continue
        if i<n-1:
            if (s[i]==">" and s[i+1]=="<") or (s[i]=="<" and s[i+1]==">"):
                ch=0
                ans-=1
                i+=2
                continue
        i+=1
    print(ans)


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

def main():
    for _ in range(int(input())):
        n=int(input())
        s=input()
        if ('>' in s and '<' not in s) or ('<' in s and '>' not in s) or ('-' in s and '<' not in s and '>' not in s):
            print(n)
        else:
            ans=0
            for x in range(n):
                if x==0:
                    if s[n-1]=='-' or s[0]=='-':
                        ans+=1
                elif x==n-1:
                    if s[x-1]=='-' or s[x]=='-':
                        ans+=1
                else:
                    if s[x]=='-' or s[x-1]=='-':
                        ans+=1
            print(ans)

#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

def main():
    for _ in range(int(input())):
        n=int(input())
        s=input()
        if ('>' in s and '<' not in s) or ('<' in s and '>' not in s) or ('-' in s and '<' not in s and '>' not in s):
            print(n)
        else:
            ans=0
            x=0
            while x<n and s[x]=='-':
                x+=1
                ans+=1
            if x<n and s[x]=='>' and '>' not in s[x+1:]:
                ans+=1
            x=n-1
            while x>=0 and s[x]=='-':
                x-=1
                ans+=1
            print(ans)

#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

def main():
    for _ in range(int(input())):
        n=int(input())
        s=input()
        if ('>' in s and '<' not in s) or ('<' in s and '>' not in s) or ('-' in s and '<' not in s and '>' not in s):
            print(n)
        else:
            ans=0
            for x in range(n):
                if x==0:
                    if s[n-1]=='-' or s[1]=='-':
                        ans+=1
                elif x==n-1:
                    if s[x-1]=='-' and s[0]=='-':
                        ans+=1
                else:
                    if s[x+1]=='-' or s[x-1]=='-':
                        ans+=1
            print(ans)

#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


import math
t = int(input())
q=[]
a=1
for i in range (t):
    n=int(input())
    s = input()
    if s == '<>':
        q.append(0)
        continue
    if ('>' in s) and ('<' in s):
        for j in range (len(s)):
            if s[j] == '-':
                a=a+1
        q.append(a)
    else:
        q.append(len(s))
for i in range (t):
    print(q[i])


q=[]
t=int(input())
ch = 0
for i in range (t):
    ch = 0
    n=int(input())
    s=input()
    s=s
    if (('<'in s) and ('>' in s)):
        if s[0] == '-':
            ch=ch+2
        for j in range (1,len(s)-1):
            if s[j] == '-':
                if s[j-1] == '-':
                    ch=+1
                else:
                    ch=+2
        if s[(len(s)-1)] =='-':
            if s[(len(s)-2)] == '-':
                ch=ch+0
            else:
                ch=ch+1
    else:
        ch = n
    q.append(ch)
for i in range(len(q)):
    print(q[i])


import math
t = int(input())
q=[]
a=1
for i in range (t):
    a = 1
    n=int(input())
    s = input()
    if s == '<>':
        q.append(0)
        continue
    if ('>' in s) and ('<' in s):
        for j in range (len(s)):
            if s[j] == '-':
                a=a+1
        q.append(a)
    else:
        q.append(len(s))
for i in range (t):
    print(q[i])