#include <bits/stdc++.h>
using namespace std;
int in[100005], out[100005], f[200005][10], g[10], head[100005], j, ff[100005],
    _next[100005], now, n, m, i, p, Time, A, B, Last, H;
char s[100005];
int getf(int k) { return ff[k] == k ? ff[k] : ff[k] = getf(ff[k]); }
bool FLAG;
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s);
  for (i = 1; i <= n; i++) {
    head[i] = i - 1;
    _next[i] = i + 1;
  }
  _next[0] = 1;
  int N = 0;
  int NN = 1;
  for (i = 1; i <= n; i++) ff[i] = i;
  while (N <= n) {
    now = N + 1;
    FLAG = false;
    p = 1;
    while (now >= 0 && now <= n + 1) {
      if (!in[now]) {
        in[now] = ++Time;
        if (now > 0) N++;
        for (i = 0; i < 10; i++) f[Time][i] = g[i];
      }
      if (now > 0 && now <= n && s[now - 1] >= '0' && s[now - 1] <= '9') {
        g[s[now - 1] - '0']++;
        s[now - 1]--;
        if (s[now - 1] < '0') {
          _next[head[now]] = _next[now];
          head[_next[now]] = head[now];
        }
        FLAG = false;
      } else {
        if (FLAG) {
          _next[head[Last]] = _next[Last];
          head[_next[Last]] = head[Last];
        }
        if (s[now - 1] == '<')
          p = 0;
        else
          p = 1;
        FLAG = true;
      }
      if (now == 0 || now == n + 1) break;
      Last = now;
      if (!p)
        for (j = getf(now); j > head[now]; j = getf(j - 1)) {
          out[j] = ++Time;
          for (i = 0; i < 10; i++) f[Time][i] = g[i];
          ff[getf(j)] = getf(j - 1);
        }
      if (p)
        now = _next[now];
      else
        now = head[now];
    }
  }
  for (i = 1; i <= n; i++)
    if (!out[i]) out[i] = Time;
  while (m--) {
    scanf("%d%d", &A, &B);
    for (i = 0; i < 10; i++)
      printf("%d ", f[min(out[A], in[B + 1])][i] - f[in[A]][i]);
    printf("\n");
  }
  return 0;
}
