#include <bits/stdc++.h>
using namespace std;
int query[109][2], cnt_digit[10];
void LANGUAGE(string t) {
  char dp = '>';
  for (int i = 0; i >= 0 && i < t.size();) {
    if (t[i] == '0') {
      cnt_digit[0]++;
      t.erase(t.begin() + i);
      i -= (dp == '<');
    } else if (t[i] >= '1' && t[i] <= '9') {
      cnt_digit[t[i] - '0']++;
      t[i]--;
      if (dp == '>')
        i++;
      else
        i--;
    } else if (t[i] == '>') {
      dp = '>';
      if (i != t.size() - 1 && (t[i + 1] == '>' || t[i + 1] == '<'))
        t.erase(t.begin() + i);
      else
        i++;
    } else if (t[i] == '<') {
      dp = '<';
      if (i != 0 && t[i - 1] == '>' || t[i - 1] == '<') t.erase(t.begin() + i);
      i--;
    }
  }
  for (int i = 0; i < 10; i++) cout << cnt_digit[i] << " ";
  cout << endl;
}
int main() {
  int n, q;
  cin >> n >> q;
  string s, t;
  cin >> s;
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    query[i][0] = x, query[i][1] = y;
  }
  for (int i = 0; i < q; i++) {
    for (int j = query[i][0]; j <= query[i][1]; j++) t += s[j];
    LANGUAGE(t);
    t.clear();
    memset(cnt_digit, 0, sizeof(cnt_digit));
  }
  return 0;
}
