#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 7, INF = 2147483647;
int n, m, Pre[N], Next[N], L[N], R[N], Pos[N], Ans[N * 10][10], Nowtime;
char S[N];
bool Book[N];
inline void GoL(int& Now) {
  L[Now] = min(L[Now], Nowtime);
  while (S[Pre[Now]] == '#') {
    L[Pre[Now]] = min(L[Pre[Now]], Nowtime);
    Pre[Now] = Pre[Pre[Now]];
  }
  Now = Pre[Now];
}
inline void GoR(int& Now) {
  R[Now] = min(R[Now], Nowtime);
  while (S[Next[Now]] == '#') {
    R[Next[Now]] = min(R[Next[Now]], Nowtime);
    Next[Now] = Next[Next[Now]];
  }
  Now = Next[Now];
}
inline void Solve(int Now) {
  int pos = Now, A;
  bool flag = 0;
  while (Now >= pos && Now <= n) {
    Book[Now] = 1;
    Pos[Now] = min(Pos[Now], (++(Nowtime)));
    A = Now;
    if (S[Now] == '<') {
      GoL(Now);
      if (S[Now] == '>' || S[Now] == '<') S[A] = '#';
      flag = 1;
    } else if (S[Now] == '>') {
      GoR(Now);
      if (S[Now] == '>' || S[Now] == '<') S[A] = '#';
      flag = 0;
    } else {
      Ans[Nowtime][S[Now] - '0'] += 1;
      if (S[Now] > '0')
        (--(S[Now]));
      else
        S[Now] = '#';
      if (flag)
        GoL(Now);
      else
        GoR(Now);
    }
  }
}
int main() {
  scanf("%d%d%s", &n, &m, S + 1);
  for (int i = (1), iLimit = (n); i <= iLimit; (++(i))) {
    Pre[i] = i - 1, Next[i] = i + 1;
    L[i] = R[i] = Pos[i] = INF;
  }
  for (int i = (1), iLimit = (n); i <= iLimit; (++(i)))
    if (!Book[i]) Solve(i);
  for (int i = (2), iLimit = (Nowtime); i <= iLimit; (++(i)))
    for (int j = (0), jLimit = (9); j <= jLimit; (++(j)))
      Ans[i][j] += Ans[i - 1][j];
  int l, r, ll, rr;
  for (int i = (1), iLimit = (m); i <= iLimit; (++(i))) {
    scanf("%d%d", &l, &r);
    ll = Pos[l] - 1, rr = min(L[l], min(R[r], Nowtime));
    for (int j = (0), jLimit = (9); j <= jLimit; (++(j)))
      printf("%d ", Ans[rr][j] - Ans[ll][j]);
    puts("");
  }
  return 0;
}
