#include <bits/stdc++.h>
using namespace std;
int scan() {
  int t = 0, m = 1;
  char c;
  c = getchar();
  while ((c < '0' || c > '9') and c != '-') c = getchar();
  if (c == '-') {
    c = getchar();
    m = -1;
  }
  while (c >= '0' && c <= '9') {
    t = (t << 3) + (t << 1) + c - '0';
    c = getchar();
  }
  return (t * m);
}
int main() {
  int l, t, hash[30], prev, flag, cp, dp, beg, end;
  char str[105], temp[105];
  scanf("%d%d\n", &l, &t);
  scanf("%s", str);
  strcpy(temp, str);
  while (t--) {
    scanf("%d%d", &beg, &end);
    beg--;
    end--;
    memset(hash, 0, sizeof(hash));
    strcpy(str, temp);
    cp = beg;
    dp = 2;
    flag = 0;
    int count = 0, tt;
    while (1) {
      if (cp > end || cp < beg) break;
      if (str[cp] != '$') count++;
      if (str[cp] >= '0' and str[cp] <= '9') {
        hash[str[cp] - '0']++;
        if (str[cp] == '0')
          str[cp] = '$';
        else
          str[cp]--;
      }
      if ((str[cp] == '<' or str[cp] == '>') and flag == 1 and
          count - tt == 1) {
        flag = 0;
        str[prev] = '$';
        tt = 0;
      }
      if (str[cp] == '<') {
        dp = 1;
        flag = 1;
        tt = count;
        prev = cp;
      }
      if (str[cp] == '>') {
        dp = 2;
        flag = 1;
        tt = count;
        prev = cp;
      }
      if (dp == 2)
        cp++;
      else
        cp--;
    }
    for (int i = 0; i < 10; i++) printf("%d ", hash[i]);
    printf("\n");
  }
}
