#include <bits/stdc++.h>
using namespace std;
int num[10];
int main() {
  int n, m, ki, kj;
  string s;
  scanf("%d%d", &n, &m);
  cin >> s;
  while (m--) {
    memset(num, 0, sizeof(num));
    scanf("%d%d", &ki, &kj);
    string s1 = s.substr(ki - 1, (kj - ki + 1));
    int dir = 1;
    int i = 0;
    while (s1.size() != 0) {
      if (i < 0 || i >= s1.size()) {
        break;
      }
      if (s1[i] >= '0' && s1[i] <= '9') {
        num[s1[i] - '0']++;
        if (s1[i] == '0') {
          s1.erase(i, 1);
          if (dir == 1) i--;
        } else {
          s1[i] = s1[i] - '0' - 1 + '0';
        }
        i += dir;
      } else {
        if (s1[i] == '>') {
          dir = 1;
          if (i + 1 >= 0 && i + 1 < s1.size() &&
              (s1[i + 1] == '<' || s1[i + 1] == '>')) {
            s1.erase(i, 1);
          } else {
            i++;
          }
          continue;
        }
        if (s1[i] == '<') {
          dir = -1;
          if (i - 1 >= 0 && i - 1 < s1.size() &&
              (s1[i - 1] == '<' || s1[i - 1] == '>')) {
            s1.erase(i, 1);
            i--;
          } else {
            i--;
          }
          continue;
        }
      }
    }
    for (int i = 0; i < 10; i++) cout << num[i] << " ";
    cout << endl;
  }
  return 0;
}
