#include <bits/stdc++.h>
using namespace std;
vector<long long> g[300005], gr[300005];
vector<bool> used;
vector<long long> order, component;
void dfs1(long long v) {
  used[v] = true;
  for (size_t i = 0; i < g[v].size(); ++i)
    if (!used[g[v][i]]) dfs1(g[v][i]);
  order.push_back(v);
}
void dfs2(long long v) {
  used[v] = true;
  component.push_back(v);
  for (size_t i = 0; i < gr[v].size(); ++i)
    if (!used[gr[v][i]]) dfs2(gr[v][i]);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    for (long long i = 0; i < n; i++) g[i].clear(), gr[i].clear();
    for (long long i = 0; i < n; i++) {
      long long a = i, b = (i + 1) % n;
      if (s[i] == '-') {
        g[a].push_back(b);
        gr[b].push_back(a);
        g[b].push_back(a);
        gr[a].push_back(b);
      } else if (s[i] == '>') {
        g[a].push_back(b);
        gr[b].push_back(a);
      } else {
        g[b].push_back(a);
        gr[a].push_back(b);
      }
    }
    used.assign(n, false);
    for (long long i = 0; i < n; ++i)
      if (!used[i]) dfs1(i);
    used.assign(n, false);
    long long ans = 0;
    for (long long i = 0; i < n; ++i) {
      long long v = order[n - 1 - i];
      if (!used[v]) {
        dfs2(v);
        if (component.size() > 1) ans += component.size();
        component.clear();
      }
    }
    order.clear();
    cout << ans << '\n';
  }
}
