#include <bits/stdc++.h>
using namespace std;
vector<int> algorithm(string prog) {
  vector<int> steps(10, 0);
  int DP = 1;
  int CP = 0;
  int L = int((prog).size());
  while (L > 0) {
    if (CP < 0 || CP >= L) break;
    if (prog[CP] != '<' && prog[CP] != '>') {
      steps[prog[CP] - 48]++;
      CP += DP;
      if (CP < 0 || CP >= L) break;
      if (prog[CP - DP] != '0') {
        prog.replace(CP - DP, 1, 1, char(prog[CP - DP] - 1));
      } else {
        prog.erase(CP - DP, 1);
        if (DP == 1) CP -= DP;
        L--;
      }
    } else {
      if (prog[CP] == '<')
        DP = -1;
      else
        DP = 1;
      CP += DP;
      if (CP < 0 || CP >= L) break;
      if (prog[CP] == '<' || prog[CP] == '>') {
        prog.erase(CP - DP, 1);
        if (DP == 1) CP -= DP;
        L--;
      }
    }
  }
  return steps;
}
int main() {
  int L, q;
  cin >> L >> q;
  string S;
  cin >> S;
  for (int t = (0); t < (q); ++t) {
    int l, r;
    cin >> l >> r;
    l--;
    string prog = S.substr(l, r - l);
    vector<int> steps = algorithm(prog);
    for (int i = (0); i < (10); ++i) {
      if (i != 0) cout << " ";
      cout << steps[i];
    }
    cout << endl;
  }
}
