#include <bits/stdc++.h>
using namespace std;
const int M = 105;
char s[M], t[M];
bool mark[M];
int n, q;
int dir(char c) {
  if (c == '<') return -1;
  if (c == '>') return 1;
}
int ans[10];
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", t);
  int l, r;
  while (q--) {
    strcpy(s, t);
    scanf("%d%d", &l, &r);
    memset(ans, 0, sizeof(ans));
    memset(mark, 0, sizeof(mark));
    int d = 1;
    int flag = 2;
    int pre = -1;
    int i = l - 1;
    while (i >= l - 1 && i < r) {
      if (s[i] >= '0' && s[i] <= '9') {
        ans[s[i] - '0']++;
        s[i] -= 1;
        if (s[i] < '0') mark[i] = 1;
        i += d;
        while (mark[i]) i += d;
        flag = 1;
      } else {
        d = dir(s[i]);
        if (flag == 0) mark[pre] = 1;
        pre = i;
        i += d;
        while (mark[i]) i += d;
        flag = 0;
      }
    }
    for (int i = 0; i < 10; i++)
      if (i == 0)
        printf("%d", ans[i]);
      else
        printf(" %d", ans[i]);
    printf("\n");
  }
  return 0;
}
