#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
clock_t clk = clock();
long long int i, j;
void solve(void);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t = 1;
  while (t--) solve();
  return 0;
}
void solve() {
  long long int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  while (q--) {
    long long int l, r;
    cin >> l >> r;
    long long int cp = 0, dp = 1;
    long long int cnt[10] = {0};
    string temp;
    for (i = l - 1; i <= r - 1; ++i) temp += s[i];
    bool prevc = 0;
    int pos = -1;
    while (cp >= 0 && cp < (int)temp.size()) {
      if (temp[cp] == '#') {
        if (dp == 1)
          ++cp;
        else
          --cp;
      }
      if (temp[cp] - '0' >= 0 && temp[cp] - '0' <= 9) {
        ++cnt[temp[cp] - '0'];
        if (temp[cp] == '0')
          temp[cp] = '#';
        else
          temp[cp] -= 1;
        if (dp == 1)
          ++cp;
        else
          --cp;
        prevc = 0;
        pos = -1;
      } else if (temp[cp] == '>' || temp[cp] == '<') {
        if (prevc == 1) {
          temp[pos] = '#';
          pos = cp;
        } else {
          prevc = 1;
          pos = cp;
        }
        if (temp[cp] == '>')
          dp = 1;
        else
          dp = 0;
        if (dp == 1)
          ++cp;
        else
          --cp;
      }
    }
    for (i = 0; i <= 9; ++i) cout << cnt[i] << " ";
    cout << '\n';
  }
}
