#include <bits/stdc++.h>
using namespace std;
bool pos(int cp, int len) { return cp >= 0 && cp < len; }
void alg(string seq) {
  vector<int> cnt(10, 0);
  vector<char> s;
  for (int i = 0; i < seq.length(); i++) s.push_back(seq[i]);
  int cp = 0, dp = 1;
  do {
    if (isdigit(s[cp])) {
      cnt[s[cp] - '0']++;
      cp += dp;
      if (pos(cp, s.size())) {
        if (s[cp - dp] != '0')
          s[cp - dp]--;
        else {
          s.erase(s.begin() + cp - dp);
          if (dp == 1) cp--;
        }
      } else
        break;
    } else {
      dp = (s[cp] == '<' ? -1 : 1);
      cp += dp;
      if (pos(cp, s.size())) {
        if (!isdigit(s[cp])) {
          s.erase(s.begin() + cp - dp);
          if (dp == 1) cp--;
        }
      } else
        break;
    }
  } while (pos(cp, s.size()));
  for (int i = 0; i < 10; i++) cout << cnt[i] << ' ';
  cout << endl;
}
int main() {
  int n, q;
  cin >> n >> q;
  string seq;
  cin >> seq;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    string tmp = seq.substr(l, r - l + 1);
    alg(tmp);
  }
  return 0;
}
