#include <bits/stdc++.h>
using namespace std;
char t[110];
char str[110];
void solve(int m) {
  int l = 1, r = 1;
  int num[15];
  memset(num, 0, sizeof(num));
  while (1) {
    if (l < 1 || l > m) break;
    if (t[l] == '<' || t[l] == '>') {
      int ll = l;
      if (t[l] == '<')
        r = -1;
      else
        r = 1;
      if (r == 1)
        l++;
      else
        l--;
      if (l < 1 || l > m) break;
      if (t[l] == '>' || t[l] == '<') {
        t[ll] = 'a';
      } else if (t[l] == 'a') {
        while (1) {
          if (r == 1)
            l++;
          else
            l--;
          if (l < 1 || l > m) break;
          if (t[l] != 'a') break;
        }
        if (l < 1 || l > m) break;
        if (t[l] == '>' || t[l] == '<') {
          t[ll] = 'a';
        }
      }
    } else {
      num[t[l] - '0']++;
      if (t[l] > '0' && t[l] <= '9') {
        t[l] = t[l] - 1;
      } else
        t[l] = 'a';
      if (r == 1) l++;
      if (r == -1) l--;
    }
  }
  for (int i = 0; i <= 9; i++) printf("%d ", num[i]);
  printf("\n");
  return;
}
int main() {
  int m, n, q, l, r;
  while (~scanf("%d%d", &n, &q)) {
    memset(str, 0, sizeof(str));
    scanf("%s", str + 1);
    while (q--) {
      scanf("%d%d", &l, &r);
      memset(t, 0, sizeof(t));
      m = 0;
      for (int i = l; i <= r; i++) {
        t[++m] = str[i];
      }
      solve(m);
    }
  }
  return 0;
}
