#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  while (q--) {
    int frq[10] = {};
    int st, en;
    cin >> st >> en;
    st--, en--;
    string l;
    for (int i = st; i <= en; ++i) l.push_back(s[i]);
    bool del[100] = {};
    int pos = 0, dir = 1;
    int prv = -1;
    while (pos > -1 && pos < l.size()) {
      if (l[pos] == '>' || l[pos] == '<') {
        if (~prv && (l[prv] == '>' || l[prv] == '<')) del[prv] = 1;
        dir = (l[pos] == '>') ? 1 : -1;
      } else {
        frq[l[pos] - '0']++;
        if (l[pos]-- == '0') del[pos] = 1;
      }
      prv = pos;
      pos += dir;
      while (del[pos] && pos >= 0) pos += dir;
    }
    for (int i = 0; i < 10; ++i) cout << frq[i] << " \n"[i == 9];
  }
  return 0;
}
