#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, times, nx[N][2], pr[N], vis[N], ans[N * 20][10];
char s[N];
vector<int> sv[N];
void mark(int i) {
  sv[i].push_back(++times);
  for (int k = 0; k <= 9; ++k) ans[times][k] = ans[times - 1][k];
}
void del(int i) {
  nx[nx[i][0]][1] = nx[i][1];
  nx[nx[i][1]][0] = nx[i][0];
}
void prepare() {
  for (int i = 1; i <= n; ++i) nx[i][0] = i - 1, nx[i][1] = i + 1;
  nx[0][1] = 1;
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      int p = i, dr = 1;
      while (i <= p && p <= n) {
        mark(p);
        if (!vis[p]) {
          vis[p] = 1;
          pr[p] = nx[p][0];
        }
        if ('0' <= s[p] && s[p] <= '9') {
          ++ans[times][s[p] - '0'];
          if (s[p] == '0')
            del(p);
          else
            --s[p];
        } else {
          dr = (s[p] == '>');
        }
        int np = nx[p][dr];
        if ((s[p] == '<' || s[p] == '>') && (s[np] == '<' || s[np] == '>')) {
          del(p);
        }
        p = np;
      }
      mark(p);
    }
}
int find(vector<int> sv, int x) {
  vector<int>::iterator it = lower_bound(sv.begin(), sv.end(), x);
  if (it == sv.end()) return times + 1;
  return *it;
}
int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  prepare();
  for (int im = 1; im <= m; ++im) {
    int l, r;
    scanf("%d%d", &l, &r);
    int t0 = sv[l][0];
    int t1 = min(find(sv[pr[l]], t0), find(sv[r + 1], t0));
    for (int k = 0; k <= 9; ++k) printf("%d ", ans[t1 - 1][k] - ans[t0 - 1][k]);
    puts("");
  }
}
