#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e8;
int a[11];
void clc(string s) {
  int j = -1, f = 1;
  for (int i = 0; i <= s.size() - 1 && i >= 0;) {
    if (s[i] == '*') {
      (f) ? i += 1 : i -= 1;
      continue;
    }
    if (s[i] == '>') {
      f = 1, i += 1;
      if ((s[j] == '>' || s[j] == '<') && (i - 1 != j)) s[j] = '*';
    } else if (s[i] == '<') {
      f = 0, i -= 1;
      if ((s[j] == '>' || s[j] == '<')) s[j] = '*';
    } else {
      a[s[i] - '0'] += 1;
      s[i] -= 1;
      if (s[i] < '0') s[i] = '*';
      (f) ? i += 1 : i -= 1;
    }
    j = (f) ? i - 1 : i + 1;
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int l, r;
  while (q--) {
    cin >> l >> r;
    memset(a, 0, sizeof(a));
    clc(s.substr(l - 1, (r - l + 1)));
    for (int i = 0; i < 10; i++) cout << a[i] << " ";
    cout << endl;
  }
}
