#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
string S;
int nxt[maxn][2];
int moveNext(int cp, int dp) {
  if (cp == -1 || cp == S.size() || S[cp]) return cp;
  return nxt[cp][dp == 1 ? 1 : 0] = moveNext(nxt[cp][dp == 1 ? 1 : 0], dp);
}
void Delete(int cp) { S[cp] = 0; }
int L[maxn], R[maxn];
int main() {
  int N, M;
  cin >> N >> M >> S;
  vector<vector<int> > ireg(M);
  vector<vector<int> > ereg(M);
  set<int> starts;
  map<int, vector<int> > enter;
  map<int, set<int> > available;
  S = "0" + S + "0";
  for (int i = 0; i < S.size(); ++i) {
    nxt[i][0] = i - 1;
    nxt[i][1] = i + 1;
  }
  for (int i = 0; i < M; ++i) {
    scanf("%d%d", &L[i], &R[i]);
    ++R[i];
    starts.insert(L[i]);
    enter[L[i]].push_back(i);
  }
  vector<int> regs(10, 0);
  while (!starts.empty()) {
    int strt = *starts.begin();
    int cp = strt;
    int dp = 1;
    while (strt <= cp) {
      vector<int>& V = enter[cp];
      for (int i = 0; i < V.size(); ++i) {
        ireg[V[i]] = regs;
        available[R[V[i]]].insert(V[i]);
        available[moveNext(L[V[i]] - 1, -1)].insert(V[i]);
      }
      V.clear();
      starts.erase(cp);
      if (isdigit(S[cp])) {
        ++regs[S[cp] - '0'];
        if (S[cp]-- == '0') {
          Delete(cp);
        }
        cp = moveNext(cp + dp, dp);
      } else if (S[cp] == '<' || S[cp] == '>') {
        dp = (S[cp] == '<') ? -1 : 1;
        int ncp = moveNext(cp + dp, dp);
        if (S[ncp] == '<' || S[ncp] == '>') {
          Delete(cp);
        }
        cp = ncp;
      }
      if (cp == S.size()) break;
      set<int>& st = available[cp];
      while (!st.empty()) {
        int ind = *st.begin();
        ereg[ind] = regs;
        available[R[ind]].erase(ind);
        available[moveNext(L[ind] - 1, -1)].erase(ind);
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < 10; ++j) {
      printf("%d%c", ereg[i][j] - ireg[i][j], " \n"[j == 9]);
    }
  }
  return 0;
}
