#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100050;
int n, q;
int f[Maxn][2], num[Maxn * 20][10], vis[Maxn];
char prog[Maxn];
void Work() {
  int r = 0, clock = 0, pos, dir;
  memset(f, 0x3f, sizeof f);
  while (true) {
    pos = r + 1, dir = 1;
    if (pos > n) break;
    while (true) {
      clock++, f[pos][dir > 0] = min(f[pos][dir > 0], clock);
      for (int i = 0; i <= 9; ++i) num[clock][i] += num[clock - 1][i];
      if (!pos || pos > n) break;
      r = max(r, pos);
      if (prog[pos] >= '0' && prog[pos] <= '9') {
        num[clock + 1][prog[pos] - '0']++;
        if (prog[pos] == '0')
          vis[pos] = 1;
        else
          prog[pos]--;
        while (pos >= 1 && vis[pos + dir] && pos <= n) {
          pos += dir;
          f[pos][dir > 0] = min(f[pos][dir > 0], clock + 1);
        }
        pos += dir;
      } else {
        int tmp = pos;
        if (prog[pos] == '>')
          dir = 1;
        else
          dir = -1;
        while (pos >= 1 && vis[pos + dir] && pos <= n) {
          pos += dir;
          f[pos][dir > 0] = min(f[pos][dir > 0], clock + 1);
        }
        pos += dir;
        if (prog[pos] == '>' || prog[pos] == '<') vis[tmp] = 1;
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", prog + 1);
  Work();
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int start = f[l][1], end = min(f[l - 1][0], f[r + 1][1]);
    for (int i = 0; i <= 9; ++i) printf("%d ", num[end][i] - num[start][i]);
    puts("");
  }
  return 0;
}
