#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000,100000000")
using namespace std;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
vector<char> S, V;
long long cnt[25];
int main(void) {
  long long n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    S.push_back(s[i]);
  }
  while (m--) {
    long long L, R;
    cin >> L >> R;
    L--;
    R--;
    V.clear();
    for (int i = L; i <= R; i++) {
      V.push_back(S[i]);
    }
    long long where = 0, j = 1;
    memset(cnt, 0, sizeof(cnt));
    while (1) {
      if (where < 0 || where >= V.size()) {
        break;
      }
      long long i = where;
      if (V[i] >= '0' && V[i] <= '9') {
        cnt[V[i] - '0']++;
        V[i]--;
        where += j;
        if (V[i] < '0') {
          V.erase(V.begin() + i);
          if (j == 1) where--;
        }
      } else {
        if (V[i] == '>') j = 1;
        if (V[i] == '<') j = -1;
        where += j;
        i += j;
        if (where < 0 || where >= V.size()) {
          break;
        }
        while (1) {
          if (where < 0 || where >= V.size()) {
            break;
          }
          i = where;
          if (V[i] == '>' && j == -1) {
            j = 1;
            V.erase(V.begin() + i + 1);
            where += j;
          } else if (V[i] == '>' && j == 1) {
            j = 1;
            V.erase(V.begin() + i - 1);
            where--;
            where += j;
          } else if (V[i] == '<' && j == -1) {
            j = -1;
            V.erase(V.begin() + i + 1);
            where += j;
          } else if (V[i] == '<' && j == 1) {
            j = -1;
            V.erase(V.begin() + i - 1);
            where--;
            where += j;
          } else
            break;
        }
      }
    }
    for (int i = 0; i <= 9; i++) {
      cout << cnt[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
