#include <bits/stdc++.h>
using namespace std;
vector<int> query(string s) {
  ;
  vector<int> ans(10, 0);
  vector<bool> valid(s.size(), true);
  int cp = 0;
  int dir = 1;
  bool last_is_dir = false;
  while (s.size()) {
    ;
    ;
    if (isdigit(s[cp])) {
      int d = s[cp] - '0';
      ;
      ans[d]++;
      if (d == 0) {
        s.erase(cp, 1);
        if (dir == -1) cp--;
      } else {
        s[cp]--;
        cp += dir;
      }
    } else {
      if (s[cp] == '>')
        dir = 1;
      else if (s[cp] == '<')
        dir = -1;
      else
        assert(false);
      int np = cp + dir;
      ;
      if (np < 0 || np >= s.size()) break;
      if (s[np] == '>' || s[np] == '<') {
        s.erase(cp, 1);
        if (dir == -1) cp--;
      } else {
        cp = np;
      }
    }
    if (cp < 0 || cp >= s.size()) break;
  }
  return ans;
}
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    int len = r - l + 1;
    vector<int> ans = query(s.substr(l, len));
    bool first = true;
    for (int i = 0; i < ans.size(); i++) {
      if (first)
        first = false;
      else
        cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}
