#include <bits/stdc++.h>
using namespace std;
const int MaxN(100003);
int Next[MaxN][2], Pre[MaxN], n, Q, t;
int Cnt[10], Tot[MaxN * 50][10];
char s[MaxN];
vector<int> T[MaxN];
inline void Erase(int i) {
  Next[Next[i][0]][1] = Next[i][1];
  Next[Next[i][1]][0] = Next[i][0];
}
bool solve() {
  for (int i = Next[0][0], k = 0;; i = Next[i][k]) {
    for (int j = 0; j <= 9; j++) Tot[t][j] = Cnt[j];
    if (T[i].empty()) Pre[i] = Next[i][1];
    T[i].push_back(t++);
    if (!i) return false;
    if (i == n + 1) return true;
    if (s[i] > '9') {
      k = s[i] == '<';
      if (!Next[i][k] || s[Next[i][k]] > '9') Erase(i);
    } else {
      ++Cnt[s[i] - '0'];
      if (s[i]-- == '0') Erase(i);
    }
  }
}
inline int getT(int x, int t) {
  auto i = lower_bound(T[x].begin(), T[x].end(), t);
  return i == T[x].end() ? INT_MAX : *i;
}
int main() {
  scanf("%d%d%s", &n, &Q, s + 1);
  for (int i = 0; i <= n; i++) Next[i][0] = i + 1, Next[i + 1][1] = i;
  Next[0][1] = 0, Next[n + 1][0] = n + 1;
  while (!solve())
    ;
  while (Q--) {
    int a, b, l, r;
    scanf("%d%d", &a, &b);
    l = T[a][0];
    r = min(getT(Pre[a], l), getT(b + 1, l));
    for (int i = 0; i <= 9; i++)
      printf("%d%c", Tot[r][i] - Tot[l][i], " \n"[i == 9]);
  }
  return 0;
}
