#include <bits/stdc++.h>
using namespace std;
vector<int> processInput(string input) {
  vector<int> numbers(10);
  bool isRight = true;
  int i = 0;
  while (i < input.size() && i >= 0) {
    if (isdigit(input[i])) {
      numbers[input[i] - '0']++;
      if (input[i] == '0') {
        input.erase(input.begin() + i, input.begin() + i + 1);
        if (isRight) i--;
      } else {
        input[i]--;
      }
      if (isRight)
        i++;
      else {
        i--;
      }
    } else {
      if (input[i] == '<')
        isRight = false;
      else {
        isRight = true;
      }
      if (isRight) {
        i++;
        if (i < input.length() && (input[i] == '<' || input[i] == '>')) {
          input.erase(input.begin() + i - 1, input.begin() + i);
          i--;
        }
      } else {
        i--;
        if (i >= 0 && (input[i] == '<' || input[i] == '>')) {
          input.erase(input.begin() + i + 1, input.begin() + i + 2);
        }
      }
    }
  }
  return numbers;
}
int main() {
  int n, q;
  cin >> n >> q;
  string sequence;
  cin >> sequence;
  while (q--) {
    int l, r;
    cin >> l >> r;
    vector<int> numbers = processInput(sequence.substr(l - 1, r - l + 1));
    for (int i = 0; i < 9; i++) {
      cout << numbers[i] << ' ';
    }
    cout << numbers[9] << endl;
  }
  return 0;
}
