#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const double PI = acos(-1);
const int INF = (int)1E9 + 5;
const double EPS = 1E-11;
const long long MOD = (long long)1E9 + 7;
int ntest = 0, test = 0;
inline void init();
inline void run();
inline void stop() { ntest = test - 1; }
int main() {
  init();
  while (++test <= ntest) {
    run();
  }
  return 0;
}
inline void init() { ntest = 1; }
inline bool isDig(char s) { return s >= '0' && s <= '9'; }
inline bool isSpec(char s) { return s == '<' || s == '>'; }
inline vector<int> go(string s) {
  vector<int> res(10, 0);
  int cur, dir = 1;
  cur = 0;
  while (cur >= 0 && cur < ((int)(s).size())) {
    if (isDig(s[cur])) {
      res[s[cur] - '0']++;
      if (s[cur] == '0') {
        s = s.erase(cur, 1);
        if (dir == -1) {
          cur--;
        }
      } else {
        s[cur] = s[cur] - 1;
        cur += dir;
      }
    } else {
      int prevCur = cur;
      dir = (s[cur] == '<') ? -1 : 1;
      cur += dir;
      if (cur >= 0 && cur < ((int)(s).size()) && isSpec(s[cur])) {
        s.erase(prevCur, 1);
        cur -= prevCur < cur;
      }
    }
  }
  return res;
}
inline void run() {
  int n, q, l, r;
  string s;
  cin >> n >> q >> s;
  for (int i = 0, _a = q; i < _a; i++) {
    cin >> l >> r;
    --l, --r;
    string newString = s.substr(l, r - l + 1);
    vector<int> res = go(newString);
    for (int i = 0, _a = ((int)(res).size()); i < _a; i++) {
      cout << res[i];
      if (i != ((int)(res).size()) - 1)
        cout << " ";
      else
        cout << endl;
    }
  }
}
