#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
int arr[10];
void calc(int l, int r) {
  string cur = s.substr(l - 1, r - l + 1);
  int pos = 0;
  int dir = 1;
  while (pos > -1 && pos < (int)cur.size()) {
    if (isdigit(cur[pos])) {
      arr[cur[pos] - '0']++;
      if (cur[pos] == '0') {
        cur.erase(cur.begin() + pos);
        if (dir != 1) pos += dir;
      } else {
        cur[pos]--;
        pos += dir;
      }
    } else {
      if (cur[pos] == '>')
        dir = 1;
      else
        dir = -1;
      if (pos + dir < 0 || pos + dir >= (int)cur.size()) break;
      if (!isdigit(cur[pos + dir])) {
        cur.erase(cur.begin() + pos);
        if (dir != 1) pos += dir;
      } else
        pos += dir;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q >> s;
  for (int i = 0; i < q; ++i) {
    memset(arr, 0, sizeof arr);
    int l, r;
    cin >> l >> r;
    calc(l, r);
    for (int i = 0; i < 10; ++i) cout << arr[i] << " ";
    cout << endl;
  }
  return 0;
}
