#include <bits/stdc++.h>
using namespace std;
map<int, vector<int>> mp;
int ans, timee = 0;
void dfsUtil(int u, vector<int> &disc, vector<int> &low, stack<int> &st,
             vector<bool> &stM) {
  disc[u] = low[u] = ++timee;
  st.push(u);
  stM[u] = true;
  for (auto i : mp[u]) {
    int v = i;
    if (disc[v] == -1) {
      dfsUtil(v, disc, low, st, stM);
      low[u] = min(low[u], low[v]);
    } else if (stM[v] == true)
      low[u] = min(low[u], disc[v]);
  }
  int w = 0;
  if (low[u] == disc[u]) {
    int curr = 0;
    while (st.top() != u) {
      w = (int)st.top();
      curr++;
      stM[w] = false;
      st.pop();
    }
    w = (int)st.top();
    if (curr != 0) ans++;
    ans += curr;
    stM[w] = false;
    st.pop();
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    ans = 0;
    timee = 0;
    string s;
    cin >> s;
    mp.clear();
    for (int i = 0; i < n; ++i) {
      if (s[i] == '-') {
        mp[i].push_back((i + 1) % n);
        mp[(i + 1) % n].push_back(i);
      } else if (s[i] == '<') {
        mp[(i + 1) % n].push_back(i);
      } else
        mp[i].push_back((i + 1) % n);
    }
    vector<int> disc(n, -1);
    vector<int> low(n, -1);
    vector<bool> stM(n, false);
    stack<int> st;
    for (int i = 0; i < n; i++)
      if (disc[i] == -1) dfsUtil(i, disc, low, st, stM);
    cout << ans << endl;
  }
  return 0;
}
