#include <bits/stdc++.h>
using namespace std;
int tot, N, M, s[100005 * 40][10];
bool b[100005];
char S[100005];
vector<int> v[100005];
void add(int p, int x) {
  v[p].push_back(++tot);
  for (int i = 0; i <= 9; i++) s[tot][i] = s[tot - 1][i] + (x == i);
}
void work() {
  for (int i = 1, j, d, w, p; i <= N; i++)
    if (!b[i]) {
      for (j = i, d = 1, p = 0; w = -1, b[j] = 1, i <= j && j <= N; j += d) {
        if (S[j]) {
          if (isdigit(S[j]))
            w = S[j] - 48, S[j]--, p = 0;
          else if (S[j] == '<' || S[j] == '>') {
            d = S[j] == '>' ? 1 : -1;
            if (p) S[p] = 0;
            p = j;
          }
        }
        add(j, w);
      }
      add(j, -1);
    }
}
void doit() {
  scanf("%d%d%s", &N, &M, S + 1);
  work();
  for (int i = 0; i <= N + 1; i++) v[i].push_back(1e9);
  for (int i = 1, l, r; i <= M; i++) {
    scanf("%d%d", &l, &r);
    int ll = v[l][0],
        rr = min(*lower_bound(v[l - 1].begin(), v[l - 1].end(), ll),
                 v[r + 1][0]);
    for (int j = 0; j <= 9; j++)
      printf("%d%c", s[rr - 1][j] - s[ll - 1][j], j == 9 ? '\n' : ' ');
  }
}
int main() {
  doit();
  return 0;
}
