#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int ans[10];
void f(string s) {
  int i = 0, dp = 1;
  int ans[10] = {0};
  while (0 <= i && i < s.length()) {
    bool erase = false;
    if ('0' <= s[i] && s[i] <= '9') {
      ans[s[i] - '0']++;
      s[i]--;
      if (s[i] < '0') erase = true;
    } else {
      if (s[i] == '<')
        dp = -1;
      else
        dp = 1;
      if (i + dp >= 0 && i + dp < s.length() &&
          (s[i + dp] == '<' || s[i + dp] == '>'))
        erase = true;
    }
    if (erase) {
      s.erase(i, 1);
      if (dp == -1) i--;
    } else
      i += dp;
  }
  for (int i = 0; i < 10; i++) printf("%d ", ans[i]);
  printf("\n");
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  string s;
  cin >> s;
  int l, r;
  while (q--) {
    scanf("%d %d", &l, &r);
    f(s.substr(l - 1, r - l + 1));
  }
  return 0;
}
