#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int Len, Qry;
  cin >> Len >> Qry >> s;
  while (Qry--) {
    int pL, pR;
    cin >> pL >> pR;
    string t;
    t = s.substr(pL - 1, pR - pL + 1);
    int cp = 0, dp = 1;
    int Count[10] = {0};
    while (cp >= 0 && cp < t.length()) {
      if (t[cp] >= '0' && t[cp] <= '9') {
        Count[t[cp] - '0']++;
        if (t[cp] == '0') {
          t.erase(cp, 1);
          if (!dp) --cp;
        } else {
          t[cp]--;
          cp += dp ? 1 : -1;
        }
      } else {
        if (t[cp] == '>') {
          dp = 1;
          ++cp;
          if (cp < t.length() && (t[cp] == '>' || t[cp] == '<'))
            t.erase(--cp, 1);
        } else {
          dp = 0;
          --cp;
          if (cp >= 0 && (t[cp] == '>' || t[cp] == '<')) t.erase(cp + 1, 1);
        }
      }
    }
    for (int i(0); i < 10; ++i) cout << Count[i] << " ";
    cout << endl;
  }
  return 0;
}
