#include <bits/stdc++.h>
using namespace std;
using namespace std;
int a[10], r1, n, k, i, j;
int pam, dp, flag;
int l, r;
vector<char> f;
int main() {
  string s, s1;
  cin >> k >> n;
  cin >> s;
  for (int(i) = 0; (i) < (n); ++(i)) {
    memset((a), 0, sizeof(a));
    cin >> l >> r;
    s1.clear();
    for (int(j) = (l - 1); (j) <= (r - 1); ++(j)) s1.push_back(s[j]);
    int j = 0;
    dp = 1;
    flag = 0;
    while (j >= 0 && j < (int)s1.size()) {
      if (s1[j] >= '0' && s1[j] <= '9') {
        a[s1[j] - '0']++;
        if (s1[j] == '0')
          s1[j] = '-';
        else
          s1[j] = (char)((int)s1[j] - 1);
        flag = 0;
      } else if (s1[j] == '>') {
        if (flag) s1[pam] = '-';
        pam = j;
        flag = 1;
        dp = 1;
      } else if (s1[j] == '<') {
        if (flag) s1[pam] = '-';
        pam = j;
        flag = 1;
        dp = -1;
      }
      j += dp;
    }
    for (int(j) = 0; (j) < (10); ++(j)) cout << a[j] << " ";
    cout << endl;
  }
  return 0;
}
