#include <bits/stdc++.h>
using namespace std;
const int N = 100005, inf = 0x3f3f3f3f;
int n, Q;
char S[N];
int in[N][10], lout[N][10], rout[N][10], now[10], nxt[N], pre[N];
int arrive[N], l_leave[N], r_leave[N], a[N];
int move(int x, int direction) {
  if (direction == -1 && !l_leave[x]) {
    l_leave[x] = 1;
    for (register int i = 0; i <= 9; ++i) lout[x][i] = now[i];
  }
  if (direction == 1 && !r_leave[x]) {
    r_leave[x] = 1;
    for (register int i = 0; i <= 9; ++i) rout[x][i] = now[i];
  }
  if (a[x] == -3 && l_leave[x] && r_leave[x])
    nxt[pre[x]] = nxt[x], pre[nxt[x]] = pre[x];
  if (direction == -1)
    return pre[x];
  else
    return nxt[x];
}
void walk(int x, int direction) {
  if (!arrive[x]) {
    arrive[x] = 1;
    for (register int i = 0; i <= 9; ++i) in[x][i] = now[i];
  }
  if (a[x] == -1)
    direction = -1;
  else if (a[x] == -2)
    direction = 1;
  else {
    ++now[a[x]], --a[x];
    if (a[x] == -1) a[x] = -3;
  }
  int y = move(x, direction);
  while (y >= 1 && y <= n && a[y] == -3) y = move(y, direction);
  if (y >= 1 && y <= n) {
    if ((a[y] == -1 || a[y] == -2) && (a[x] == -1 || a[x] == -2)) a[x] = -3;
    walk(y, direction);
  }
}
int main() {
  scanf("%d%d", &n, &Q);
  scanf("%s", S + 1);
  for (register int i = 1; i <= n; ++i) {
    if (S[i] == '<')
      a[i] = -1;
    else if (S[i] == '>')
      a[i] = -2;
    else
      a[i] = S[i] - '0';
    nxt[i] = i + 1, pre[i] = i - 1;
  }
  for (register int i = 1; i <= n; ++i)
    for (register int j = 0; j <= 9; ++j) lout[i][j] = rout[i][j] = inf;
  for (register int i = 1; i <= n; ++i)
    if (!arrive[i]) walk(i, 1);
  while (Q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    for (register int j = 0; j <= 9; ++j)
      printf("%d ", min(lout[l][j], rout[r][j]) - in[l][j]);
    puts("");
  }
  return 0;
}
