#include <bits/stdc++.h>
using namespace std;
void remove(string &t, int &CP, int index);
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    string t = s.substr(l - 1, r - l + 1);
    int CP = 0;
    bool DP = true;
    int freq[10] = {0};
    bool prev = false;
    bool prevCP = false;
    while (CP >= 0 && CP < t.length()) {
      if (t[CP] <= '9' && t[CP] >= '0') {
        freq[t[CP] - '0']++;
        if (DP)
          CP++;
        else
          CP--;
        if (DP) {
          if (t[CP - 1] > '0')
            t[CP - 1] = t[CP - 1] - 1;
          else
            remove(t, CP, CP - 1);
        } else {
          if (t[CP + 1] > '0')
            t[CP + 1] = t[CP + 1] - 1;
          else
            remove(t, CP, CP + 1);
        }
        prev = false;
      } else if (t[CP] == '<') {
        if (prev) {
          if (prevCP)
            remove(t, CP, CP + 1);
          else
            remove(t, CP, CP - 1);
        }
        DP = false;
        prev = true;
        prevCP = true;
        if (DP)
          CP++;
        else
          CP--;
      } else if (t[CP] == '>') {
        if (prev) {
          if (prevCP)
            remove(t, CP, CP + 1);
          else
            remove(t, CP, CP - 1);
        }
        DP = true;
        prev = true;
        prevCP = false;
        if (DP)
          CP++;
        else
          CP--;
      }
    }
    for (int f = 0; f < 10; f++) {
      if (f != 0) cout << " ";
      cout << freq[f];
    }
    cout << endl;
  }
  return 0;
}
void remove(string &t, int &CP, int index) {
  if (CP > index) CP--;
  string temp = "";
  for (int i = 0; i < index; i++) {
    temp = temp + t[i];
  }
  for (int i = index + 1; i < t.length(); i++) {
    temp = temp + t[i];
  }
  t = temp;
  return;
}
