#include <bits/stdc++.h>
char str[105];
char ss[105];
int vis[105];
int num[10];
int main() {
  int i, n, m, a, b;
  while (~scanf("%d%d", &n, &m)) {
    scanf(" %s", str);
    while (m--) {
      memset(num, 0, sizeof(num));
      memcpy(ss, str, sizeof(str));
      memset(vis, 0, sizeof(vis));
      scanf("%d%d", &a, &b);
      a--;
      b--;
      int y = 1, flag = 0, pre = 0;
      for (i = a; i >= a && i <= b; i += y) {
        if (vis[i] == 1) continue;
        if (ss[i] >= '0' && ss[i] <= '9') {
          num[ss[i] - '0']++;
          if (ss[i] == '0')
            vis[i] = 1;
          else
            ss[i]--;
          flag = 0;
        } else if (ss[i] == '>') {
          y = 1;
          if (flag == 1) vis[pre] = 1;
          flag = 1;
          pre = i;
        } else if (ss[i] == '<') {
          y = -1;
          if (flag == 1) vis[pre] = 1;
          flag = 1;
          pre = i;
        }
      }
      for (i = 0; i < 9; i++) printf("%d ", num[i]);
      printf("%d\n", num[9]);
    }
  }
  return 0;
}
