#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, x, y, num, c, d, sum[15], t, p, f;
  char s[105];
  while (scanf("%d%d", &n, &m) != EOF) {
    vector<char> v;
    for (i = 1; i <= n; i++) cin >> s[i];
    for (i = 1; i <= m; i++) {
      c = 0;
      d = 2;
      scanf("%d%d", &x, &y);
      memset(sum, 0, sizeof(sum));
      v.clear();
      for (j = x; j <= y; j++) v.push_back(s[j]);
      while (!(c < 0 || c == v.size())) {
        if (v[c] == '>') {
          d = 2;
          c++;
          if (v[c] == '<' || v[c] == '>') {
            t = c - 1;
            v.erase(v.begin() + t);
            c--;
          }
        } else if (v[c] == '<') {
          d = 1;
          c--;
          if (v[c] == '>' || v[c] == '<') {
            t = c + 1;
            v.erase(v.begin() + t);
          }
        } else if (v[c] >= '0' || v[c] <= '9') {
          if (v[c] == '0') {
            sum[0]++;
            t = c;
            if (d == 1) {
              c--;
              v.erase(v.begin() + t);
            } else {
              c++;
              v.erase(v.begin() + t);
              c--;
            }
          } else {
            sum[v[c] - '0']++;
            v[c] = v[c] - 1;
            if (d == 1)
              c--;
            else
              c++;
          }
        }
      }
      for (p = 0; p <= 9; p++) {
        if (p == 0)
          printf("%d", sum[p]);
        else
          printf(" %d", sum[p]);
      }
      printf("\n");
    }
  }
  return 0;
}
