#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int ST = 100010;
const int ST1 = 1000010;
const long long MOD = 1000000007;
long long ABS(long long a) {
  if (a < 0)
    return a * (-1);
  else
    return a;
}
void ex(string a) {
  vector<int> ans(10);
  int uk = 1;
  bool nap = true;
  char pr = 0;
  while (a[uk] != '?') {
    if (a[uk] >= '0' && a[uk] <= '9') {
      ans[a[uk] - '0']++;
      a[uk]--;
      if (a[uk] == 47) {
        a.erase(a.begin() + uk);
        if (!nap) uk--;
      } else {
        if (nap)
          uk++;
        else
          uk--;
      }
    } else {
      int pr = uk;
      if (a[uk] == '>')
        nap = true;
      else
        nap = false;
      if (nap) {
        uk++;
        if (a[uk] == '>' || a[uk] == '<') {
          a.erase(a.begin() + pr);
          uk--;
        }
      } else {
        uk--;
        if (a[uk] == '>' || a[uk] == '<') {
          a.erase(a.begin() + pr);
        }
      }
    }
  }
  for (int i = 0; i < 10; i++) cout << ans[i] << " ";
  cout << endl;
}
int main() {
  int n, q;
  cin >> n >> q;
  string c;
  cin >> c;
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    string pos = "?";
    for (int i = a; i <= b; i++) pos += c[i];
    pos += "?";
    ex(pos);
  }
  return 0;
}
