#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200010;
const int inf = 1 << 23;
int n, Q;
char s[Maxn];
int f[Maxn], g[Maxn], ans[Maxn * 5][10], t;
int nxt[Maxn], pre[Maxn];
bool v[Maxn];
int _min(int x, int y) { return x < y ? x : y; }
int main() {
  int i, j, k;
  scanf("%d%d", &n, &Q);
  scanf("%s", s + n);
  for (i = 0; i < n; i++) s[i] = '>';
  for (i = 0; i <= 2 * n - 1; i++) f[i] = g[i] = inf;
  for (i = 0; i <= 2 * n - 1; i++) nxt[i] = i + 1;
  for (i = 0; i <= 2 * n - 1; i++) pre[i + 1] = i;
  t = 0;
  i = n;
  int fx = 1, last = 0;
  while (i <= 2 * n - 1) {
    if (fx == 1) {
      if (f[i] == inf) f[i] = t;
    } else {
      if (g[i] == inf) g[i] = t;
    }
    if (v[i]) {
      if (g[i] != inf) {
        nxt[pre[i]] = nxt[i];
        pre[nxt[i]] = pre[i];
      }
      if (fx == 1)
        i = nxt[i];
      else
        i = pre[i];
      continue;
    }
    if (s[i] >= '0' && s[i] <= '9') {
      t++;
      for (j = 0; j < 10; j++) ans[t][j] = ans[t - 1][j];
      ans[t][s[i] - '0']++;
      if (s[i] == '0') v[i] = true;
      s[i]--;
      last = 0;
    } else {
      if (last > 0) v[last] = true;
      last = i;
      if (s[i] == '>')
        fx = 1;
      else
        fx = -1;
    }
    if (fx == 1)
      i = nxt[i];
    else
      i = pre[i];
  }
  f[i] = t;
  while (Q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int tl = f[l + n - 1], tr = _min(g[l + n - 2], f[r + n]);
    for (i = 0; i < 10; i++)
      printf("%d%c", ans[tr][i] - ans[tl][i], i == 9 ? '\n' : ' ');
  }
  return 0;
}
