#include <bits/stdc++.h>
using namespace std;
int l[110000], r[110000], rec[110000], Min[110000 * 10][21],
    Max[110000 * 10][21], s[110000 * 10][10], n, q, num = 0;
char str[110000];
bool vis[110000];
void del(int x) {
  r[l[x]] = r[x];
  l[r[x]] = l[x];
}
void debug(int t) {
  int i = r[0];
  while (i < n + 1) {
    printf("%c", str[i]);
    i = r[i];
  }
  printf("\n");
  cout << t << endl;
}
void work(int i, int z) {
  int last = 0, st = i;
  while (1) {
    if (!vis[i]) {
      vis[i] = 1;
      rec[i] = num + 1;
    }
    ++num;
    Min[num][0] = Max[num][0] = i;
    for (int j = 0; j <= 9; j++) s[num][j] = s[num - 1][j];
    if (str[i] >= '0' && str[i] <= '9') s[num][str[i] - '0']++;
    if (str[i] == '<') {
      if (str[last] == '<' || str[last] == '>') del(last);
      z = -1, last = i, i = l[i];
    } else if (str[i] == '>') {
      if (str[last] == '<' || str[last] == '>') del(last);
      z = 1, last = i, i = r[i];
    } else {
      last = i;
      if (str[last] >= '1' && str[last] <= '9')
        str[last]--;
      else if (str[last] == '0')
        del(last);
      if (z == 1)
        i = r[i];
      else
        i = l[i];
    }
    if (i == 0 || i == n + 1 || i < st) break;
  }
  ++num;
  Max[num][0] = Min[num][0] = 0;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) l[i] = i - 1, r[i] = i + 1;
  r[0] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) work(i, 1);
  for (int i = num; i; i--)
    for (int j = 1; i + (1 << j) - 1 <= num; j++)
      Max[i][j] = max(Max[i][j - 1], Max[i + (1 << (j - 1))][j - 1]),
      Min[i][j] = min(Min[i][j - 1], Min[i + (1 << (j - 1))][j - 1]);
  while (q--) {
    int l, r, x, maxt = 0, mint = n + 1;
    scanf("%d%d", &l, &r);
    x = rec[l];
    for (int i = 20; i >= 0; i--)
      if (x + (1 << i) - 1 <= num && max(maxt, Max[x][i]) <= r &&
          min(mint, Min[x][i]) >= l) {
        maxt = max(maxt, Max[x][i]);
        mint = min(mint, Min[x][i]);
        x += 1 << i;
      }
    x--;
    for (int i = 0; i <= 9; i++) printf("%d ", s[x][i] - s[rec[l] - 1][i]);
    printf("\n");
  }
  return 0;
}
