#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
bool v[MAXN];
char s[MAXN];
int fi[MAXN], fo[MAXN];
int n, m, pos[MAXN * 10], tot, T;
int sum[MAXN * 2][10], now[10];
int suc[MAXN], pre[MAXN], r[MAXN];
void work(int S) {
  if (S == 1)
    for (int i = 1; i <= n; ++i) pre[i] = i - 1, suc[i] = i + 1;
  int i = S, dir = 1, top = 0, las = -1;
  while (i >= S && i <= n) {
    v[i] = 1;
    T++;
    int x = fi[i];
    if (!fi[i])
      fi[i] = T, r[++top] = i, pos[T] = ++tot,
      memcpy(sum[tot], now, sizeof(now));
    if (x && top && r[top] > i) {
      pos[T] = ++tot;
      memcpy(sum[tot], now, sizeof(now));
      while (x && top && r[top] > i) fo[r[top--]] = T;
    }
    if (s[i] > 47 && s[i] < 58) {
      now[s[i] - '0']++;
      if (s[i] == '0')
        pre[suc[i]] = pre[i], suc[pre[i]] = suc[i];
      else
        --s[i];
    } else {
      dir = s[i] == '>' ? 1 : -1;
      if (las != -1 && (s[las] < 48 || s[las] > 57))
        pre[suc[las]] = pre[las], suc[pre[las]] = suc[las];
    }
    las = i, i = dir == 1 ? suc[i] : pre[i];
  }
  T++;
  if (i < S && top) {
    pos[T] = ++tot;
    memcpy(sum[tot], now, sizeof(now));
    while (i < S && top) fo[r[top--]] = T;
  }
  if (i > n) fi[n + 1] = T, pos[T] = ++tot, memcpy(sum[tot], now, sizeof(now));
}
int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  fi[n + 1] = 0x7fffffff;
  memset(fo, 127, sizeof(fo));
  for (int i = 1; i <= n; i++)
    if (!v[i]) work(i);
  for (int i = 1, l, r; i <= m; i++) {
    scanf("%d%d", &l, &r);
    int a = pos[fi[l]];
    int b = pos[min(fi[r + 1], fo[l])];
    for (int j = 0; j < 10; j++)
      printf("%d%c", sum[b][j] - sum[a][j], j < 9 ? ' ' : '\n');
  }
  return 0;
}
