#include <bits/stdc++.h>
using namespace std;
vector<set<long long> > g, gr;
vector<bool> used;
vector<long long> order, component;
void dfs1(long long v) {
  used[v] = true;
  for (auto i : g[v])
    if (!used[i]) dfs1(i);
  order.push_back(v);
}
void dfs2(long long v) {
  used[v] = true;
  component.push_back(v);
  for (auto i : gr[v]) {
    if (!used[i]) {
      dfs2(i);
    }
  }
}
void test_case() {
  long long n;
  cin >> n;
  g.clear();
  gr.clear();
  used.clear();
  order.clear();
  component.clear();
  g.resize(n);
  gr.resize(n);
  string s;
  cin >> s;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '-') {
      long long a = i + 1;
      g[i].insert(a % n);
      gr[a % n].insert(i);
      long long b = i + 1;
      g[b % n].insert(i);
      gr[i].insert(b % n);
    } else if (s[i] == '>') {
      long long a = i + 1;
      g[i].insert(a % n);
      gr[a % n].insert(i);
    } else {
      long long b = i + 1;
      g[b % n].insert(i);
      gr[i].insert(b % n);
    }
  }
  long long ans = 0;
  used.assign(n, false);
  for (long long i = 0; i < n; ++i)
    if (!used[i]) dfs1(i);
  used.assign(n, false);
  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();
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long t = 1;
  cin >> t;
  while (t--) {
    test_case();
  }
}
