#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
set<int> foo;
int n, q, clk, fst[maxn], out[maxn], pre[maxn], nxt[maxn], cnt_fst[maxn][10],
    cnt_out[maxn][10], cnt[10];
char s[maxn];
int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    pre[i] = i - 1;
    nxt[i] = i + 1;
    foo.insert(i);
  }
  nxt[0] = 1;
  pre[n + 1] = n;
  s[0] = '>';
  for (int i = nxt[0], dir = 1; i <= n;) {
    ++clk;
    if (!i) {
      dir = 1;
      i = nxt[i];
      continue;
    }
    if (!fst[i]) {
      fst[i] = clk;
      memcpy(cnt_fst[i], cnt, sizeof cnt);
    }
    if (s[i] == '<') {
      dir = 0;
    }
    if (s[i] == '>') {
      dir = 1;
    }
    int j = (dir == 1 ? nxt[i] : pre[i]);
    if (s[i] == '<' || s[i] == '>') {
      if (j <= n) {
        if (s[j] == '<' || s[j] == '>') {
          pre[nxt[i]] = pre[i];
          nxt[pre[i]] = nxt[i];
        }
      }
    } else {
      ++cnt[s[i] - '0'];
      if (s[i] == '0') {
        pre[nxt[i]] = pre[i];
        nxt[pre[i]] = nxt[i];
      } else {
        --s[i];
      }
    }
    i = j;
    for (;;) {
      auto it = foo.lower_bound(j + 1);
      if (it == foo.end() || !fst[*it]) {
        break;
      }
      out[*it] = clk;
      memcpy(cnt_out[*it], cnt, sizeof cnt);
      foo.erase(it);
    }
  }
  fst[n + 1] = ++clk;
  memcpy(cnt_fst[n + 1], cnt, sizeof cnt);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (!out[l] || out[l] > fst[r + 1]) {
      for (int c = 0; c < 10; ++c) {
        printf("%d%c", cnt_fst[r + 1][c] - cnt_fst[l][c], " \n"[c == 9]);
      }
    } else {
      for (int c = 0; c < 10; ++c) {
        printf("%d%c", cnt_out[l][c] - cnt_fst[l][c], " \n"[c == 9]);
      }
    }
  }
  return 0;
}
