#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
enum { LEFT = 0, RIGHT = 1 };
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  string str;
  cin >> str;
  while (q--) {
    int print[10] = {0};
    list<char> s;
    int l, r;
    scanf("%d %d", &l, &r);
    l--, r--;
    for (int i = l; i <= r; i++) s.push_back(str[i]);
    list<char>::iterator CP = s.begin();
    int DP = RIGHT;
    do {
      bool era = false;
      bool dir = false;
      if (isdigit(*CP)) {
        print[*CP - '0']++;
        if (*CP == '0') era = true;
        (*CP)--;
      } else if (*CP == '<') {
        DP = LEFT;
        dir = true;
      } else {
        DP = RIGHT;
        dir = true;
      }
      if (era) CP = s.erase(CP);
      list<char>::iterator prev = CP;
      if (DP == LEFT) {
        CP--;
      } else {
        if (!era) CP++;
      }
      if (CP == --s.begin() || CP == s.end()) break;
      if (dir && (*CP == '<' || *CP == '>')) s.erase(prev);
    } while (CP != --s.begin() && CP != s.end());
    printf("%d", print[0]);
    for (int i = 1; i < 10; i++) printf(" %d", print[i]);
    puts("");
  }
  return 0;
}
