#include <bits/stdc++.h>
using namespace std;
char s[101], a[101];
int arr[10];
int main() {
  int n, q;
  cin >> n >> q;
  cin >> s;
  while (q--) {
    strcpy(a, s);
    memset(arr, 0, sizeof(arr));
    int ini, fin;
    cin >> ini >> fin;
    ini--;
    fin--;
    int pos = ini, dir = 1, posant = -1;
    while (pos >= ini && pos <= fin) {
      if (a[pos] == 'A') {
        pos += dir;
        continue;
      }
      if (isdigit(a[pos])) {
        posant = pos;
        arr[a[pos] - '0']++;
        if (a[pos] - '0')
          a[pos]--;
        else
          a[pos] = 'A';
      } else if (a[pos] == '<' || a[pos] == '>') {
        if (a[pos] == '<')
          dir = -1;
        else
          dir = 1;
        if (posant != -1) {
          if (a[posant] == '<' || a[posant] == '>') a[posant] = 'A';
        }
        posant = pos;
      }
      pos += dir;
    }
    for (int i = 0; i < 10; i++) cout << arr[i] << " ";
    cout << endl;
  }
  return 0;
}
