#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 1e5 + 7;
int n, q, m, f[N * 50][10];
char s[N];
vector<int> vis[N];
inline void add(int x, int k) {
  vis[x].push_back(++m);
  for (int i = 0; i <= 9; i++) f[m][i] = f[m - 1][i] + (i == k);
}
inline int query(vector<int> a, int x) {
  vector<int>::iterator it = lower_bound(a.begin(), a.end(), x);
  if (it == a.end())
    return m + 1;
  else
    return *it;
}
int main() {
  n = read(), q = read();
  scanf("%s", s + 1);
  int visfar = 0;
  while (visfar < n) {
    int thetime_begin = visfar, now = visfar + 1, k = 1, last_sign = 0;
    for (; now > thetime_begin && now <= n; now += k) {
      add(now, s[now] - '0');
      if (now > visfar) visfar = now;
      if (s[now] == 0) continue;
      if (s[now] >= '0' && s[now] <= '9') {
        if (s[now] == '0')
          s[now] = 0;
        else
          s[now]--;
      } else {
        if (s[last_sign] == '<' || s[last_sign] == '>') s[last_sign] = 0;
        if (s[now] == '<')
          k = -1;
        else
          k = 1;
      }
      last_sign = now;
    }
    add(now, -1);
  }
  for (int T = 1; T <= q; T++) {
    int l = read(), r = read();
    int head = query(vis[l], 0),
        tail = min(query(vis[l - 1], head), query(vis[r + 1], head));
    head--, tail--;
    for (int i = 0; i <= 8; i++) printf("%d ", f[tail][i] - f[head][i]);
    printf("%d\n", f[tail][9] - f[head][9]);
  }
}
