#include <bits/stdc++.h>
using namespace std;
void getans(string s) {
  int outs[10];
  int cp = 0;
  int dp = 1, i;
  memset(outs, 0, sizeof(outs));
  while (1) {
    if (cp < 0 || cp >= s.size()) break;
    if (s[cp] >= '0' && s[cp] <= '9') {
      outs[s[cp] - '0']++;
      if (s[cp] == '0') {
        s.erase(cp, 1);
        cp += dp;
        if (dp == 1) cp--;
      } else {
        s[cp]--;
        cp += dp;
      }
    } else {
      if (s[cp] == '<')
        dp = -1;
      else
        dp = 1;
      cp += dp;
      if (s[cp] == '<' || s[cp] == '>') {
        s.erase(cp - dp, 1);
        if (dp == 1) {
          cp--;
        }
      }
    }
  }
  for (i = 0; i < 10; i++) cout << outs[i] << " ";
  cout << endl;
}
int main() {
  string s;
  int n, q, l, r;
  cin >> n >> q;
  cin >> s;
  s = " " + s;
  while (q--) {
    cin >> l >> r;
    getans(s.substr(l, r - l + 1));
  }
  return 0;
}
