#include <bits/stdc++.h>
using namespace std;
const int N = 120;
char st[N];
char s[N];
int ans[10];
int n, k;
void solve(int d) {
  int zn = 1;
  int ind = 0;
  while (1) {
    while (ind >= 0 && ind < d && s[ind] == '#') ind += zn;
    if (ind == d || ind < 0) return;
    if (s[ind] >= '0' && s[ind] <= '9') {
      ans[s[ind] - '0']++;
      if (s[ind] == '0')
        s[ind] = '#';
      else
        s[ind] = s[ind] - 1;
      ind += zn;
    } else {
      if (s[ind] == '<')
        zn = -1;
      else
        zn = 1;
      int ni = ind + zn;
      while (ni >= 0 && ni < d && s[ni] == '#') ni += zn;
      if (ni >= 0 && ni < d && (s[ni] == '<' || s[ni] == '>')) s[ind] = '#';
      ind = ni;
    }
  }
}
int main() {
  scanf("%d %d\n", &n, &k);
  gets(st);
  for (int tc = 0; tc < k; tc++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    for (int i = 0; i < 10; i++) ans[i] = 0;
    for (int i = u; i <= v; i++) s[i - u] = st[i];
    solve(v - u + 1);
    for (int i = 0; i < 10; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
