#include <bits/stdc++.h>
using namespace std;
int result[10];
bool isNumber(char c) { return (c >= '0' && c <= '9'); }
void solve(string s) {
  int cp = 0;
  int dp = 1;
  while (true) {
    if (isNumber(s[cp])) {
      ++result[s[cp] - '0'];
      s[cp] = s[cp] - 1;
      if (s[cp] < '0') {
        string temp = s.substr(0, cp);
        s = temp.append(s.substr(cp + 1));
        if (dp == -1) cp = cp + dp;
      } else
        cp = cp + dp;
      if (cp < 0 || cp >= s.length()) break;
    } else {
      dp = (s[cp] == '>') ? 1 : -1;
      if ((cp + dp) < 0 || (cp + dp) >= s.length()) break;
      if (!isNumber(s[cp + dp])) {
        string temp = s.substr(0, cp);
        s = temp.append(s.substr(cp + 1));
        if (dp == -1) cp = cp + dp;
      } else
        cp = cp + dp;
    }
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  string input;
  cin >> input;
  int l, r, len;
  for (int i = 0; i < q; i++) {
    cin >> l >> r;
    len = r - l + 1;
    --l;
    for (int i = 0; i < 10; i++) {
      result[i] = 0;
    }
    solve(input.substr(l, len));
    for (int i = 0; i < 10; i++) {
      cout << result[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
