#include <bits/stdc++.h>
using namespace std;
int number[10];
int main() {
  int n, q;
  int point;
  int l, r;
  bool dp;
  string s, ms;
  while (cin >> n >> q) {
    cin >> s;
    while (q--) {
      ms = s;
      memset(number, 0, sizeof(number));
      cin >> l >> r;
      point = l - 1;
      dp = true;
      while (point >= l - 1 && point <= r - 1) {
        if (ms[point] != '<' && ms[point] != '>' && ms[point] != '/') {
          int cmp = ms[point] - '0';
          if (cmp >= 0) {
            number[cmp]++;
            ms[point]--;
          }
          if (dp == true) {
            point++;
            while (ms[point] == '/') point++;
          } else {
            point--;
            while (ms[point] == '/') point--;
          }
        } else {
          int smp = point;
          if (ms[point] == '<') {
            dp = false;
            point--;
            while (ms[point] == '/') point--;
          } else {
            dp = true;
            point++;
            while (ms[point] == '/') point++;
          }
          if (ms[point] == '<' || ms[point] == '>') ms[smp] = '/';
        }
      }
      for (int k = 0; k <= 9; k++) {
        cout << number[k];
        if (k != 9)
          cout << " ";
        else
          cout << endl;
      }
    }
  }
  return 0;
}
