#include <bits/stdc++.h>
using namespace std;
const int nn = 100005;
char a[nn];
int n, q, ql[nn], qr[nn];
int vis[nn], ex[nn], l[nn], r[nn];
int p1[nn], q1[nn], r1[nn];
int p2[nn], q2[nn], r2[nn];
int c[11], pc[nn][11], ans[nn][11];
inline void add1(int x, int y) {
  if (p1[x])
    r1[q1[x]] = y;
  else
    p1[x] = y;
  q1[x] = y;
}
inline void add2(int x, int y) {
  if (p2[x])
    r2[q2[x]] = y;
  else
    p2[x] = y;
  q2[x] = y;
}
void init() {
  scanf("%d%d%s", &n, &q, a + 1);
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d", &ql[i], &qr[i]);
    add1(ql[i] - 1, i);
    add2(qr[i] + 1, i);
  }
}
inline void update(int x) {
  if (ex[x]) return;
  ex[x] = 1;
  for (int i = 0; i <= 9; ++i) ans[x][i] = c[i] - pc[ql[x]][i];
}
inline void del(int x) {
  if (p1[x]) {
    r1[q1[x]] = p1[l[x]];
    p1[l[x]] = p1[x];
    q1[l[x]] = q1[x];
  }
  r[l[x]] = r[x];
  l[r[x]] = l[x];
}
int run(int x) {
  memset(c, 0, sizeof(c));
  int mx = x, mk = 0;
  for (int i = x, j = 0;; i = j ? l[i] : r[i]) {
    if (!vis[i]) memcpy(pc[i], c, sizeof(c));
    vis[i] = 1;
    if (j) {
      for (int k = p1[i]; k; k = r1[k]) update(k);
      p1[i] = q1[i] = 0;
    } else {
      for (int k = p2[i]; k; k = r2[k]) update(k);
      p2[i] = q2[i] = 0;
    }
    mx = max(mx, i);
    if (i < x || i > n) break;
    if (a[i] >= '0' && a[i] <= '9') {
      ++c[a[i] - 48];
      mk = 0;
      if (a[i] > '0')
        --a[i];
      else
        del(i);
    } else {
      if (mk) del(j ? r[i] : l[i]);
      j = a[i] == '<';
      mk = 1;
    }
  }
  return mx;
}
void work() {
  for (int i = 1; i <= n; ++i) l[i] = i - 1, r[i] = i + 1;
  for (int i = run(1); i <= n; i = run(i + 1))
    ;
  for (int i = 1; i <= q; ++i)
    for (int j = 0; j <= 9; ++j) {
      printf("%d", ans[i][j]);
      if (j < 9)
        printf(" ");
      else
        puts("");
    }
}
int main() {
  init();
  work();
  return 0;
}
