#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MX = 2e6;
int cnt[10][MX];
int pos = 1;
char s[100500];
bool used[100500];
int fst[100500];
int lf[100500];
int rg[100500];
int ip;
int nxtr[100500], nxtl[100500];
void mrigh() {
  rg[ip] = min(rg[ip], pos);
  while (s[nxtr[ip]] == ' ') {
    rg[nxtr[ip]] = min(rg[nxtr[ip]], pos);
    nxtr[ip] = nxtr[nxtr[ip]];
  }
  ip = nxtr[ip];
}
void mleft() {
  lf[ip] = min(lf[ip], pos);
  while (s[nxtl[ip]] == ' ') {
    lf[nxtl[ip]] = min(lf[nxtl[ip]], pos);
    nxtl[ip] = nxtl[nxtl[ip]];
  }
  ip = nxtl[ip];
}
void build(int st) {
  ip = st;
  int dir = 1;
  while (true) {
    if (ip < st || s[ip] == 0) return;
    used[ip] = true;
    fst[ip] = min(fst[ip], pos);
    int cur = ip;
    if (s[ip] == '>') {
      mrigh();
      if (s[ip] == '>' || s[ip] == '<') s[cur] = ' ';
      dir = 1;
      continue;
    }
    if (s[ip] == '<') {
      mleft();
      if (s[ip] == '>' || s[ip] == '<') s[cur] = ' ';
      dir = -1;
      continue;
    }
    cnt[s[ip] - '0'][pos] = 1;
    ++pos;
    if (s[ip] == '0')
      s[ip] = ' ';
    else
      --s[ip];
    if (dir > 0)
      mrigh();
    else
      mleft();
  }
}
int main() {
  int n, q;
  scanf("%d%d%s", &n, &q, &s);
  int len = strlen(s);
  for (int i = 0; i <= len; ++i) {
    nxtl[i] = i - 1;
    nxtr[i] = i + 1;
    fst[i] = INF;
    lf[i] = INF;
    rg[i] = INF;
  }
  for (int i = 0; i < len; ++i) {
    if (!used[i]) build(i);
  }
  for (int j = 0; j < 10; ++j)
    for (int i = 1; i < pos; ++i) {
      cnt[j][i] += cnt[j][i - 1];
    }
  for (int i = 0; i < q; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    --l;
    --r;
    int frm = fst[l] - 1;
    int to = min(lf[l], rg[r]) - 1;
    to = min(to, pos - 1);
    for (int j = 0; j < 10; ++j) {
      printf("%d ", cnt[j][to] - cnt[j][frm]);
    }
    puts("");
  }
  return 0;
}
