#include <bits/stdc++.h>
using namespace std;
int Read() {
  char c;
  while (c = getchar(), (c != '-') && (c < '0' || c > '9'))
    ;
  bool neg = (c == '-');
  int ret = (neg ? 0 : c - 48);
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + c - 48;
  return neg ? -ret : ret;
}
const int MAXN = 100005;
vector<int> p[MAXN];
int N, Q, n, cnt[MAXN * 45][10], vis[MAXN], cur[10];
char s[MAXN];
void Ins(int x) {
  p[x].push_back(++n);
  for (int i = 0; i <= 9; i++) cnt[n][i] = cur[i];
}
void init() {
  scanf("%d%d%s", &N, &Q, s + 1);
  for (int l = 1; l <= N; l++)
    if (!vis[l]) {
      int r = l;
      for (int d = 1, pre = 0; r >= l && r <= N; vis[r] = 1, Ins(r), r += d)
        if (s[r] >= '0' && s[r] <= '9')
          ++cur[s[r] - 48], --s[r], pre = 0;
        else if (s[r] == '<' || s[r] == '>')
          d = (s[r] == '>' ? 1 : -1), s[pre] = 0, pre = r;
      Ins(r);
    }
}
int FindPos(int x, int y) {
  vector<int>::iterator k = lower_bound(p[x].begin(), p[x].end(), y);
  return k < p[x].end() ? *k : 1e9;
}
void work() {
  for (int i = 1; i <= Q; i++) {
    int l = Read(), r = Read(), u = p[l][0],
        v = min(FindPos(l - 1, u), FindPos(r + 1, u));
    for (int j = 0; j <= 9; j++)
      printf("%d%c", cnt[v - 1][j] - cnt[u - 1][j], j < 9 ? ' ' : '\n');
  }
}
int main() {
  init();
  work();
  return 0;
}
