#include <bits/stdc++.h>
using namespace std;
vector<int> run(string s) {
  vector<int> res(10, 0);
  int cp = 0, dp = 1;
  while (0 < s.size() && 0 <= cp && cp < s.size()) {
    if (isdigit(s[cp])) {
      res[s[cp] - '0']++;
      if (s[cp] == '0') {
        s.erase(cp, 1);
        if (dp == -1) {
          cp -= 1;
        }
      } else {
        s[cp]--;
        cp += dp;
      }
    } else {
      if (s[cp] == '<') {
        dp = -1;
      } else {
        dp = 1;
      }
      int ncp = cp + dp;
      if (0 <= ncp && ncp < s.size() && (s[ncp] == '<' || s[ncp] == '>')) {
        s.erase(cp, 1);
        if (dp == -1) {
          cp -= 1;
        }
      } else {
        cp = ncp;
      }
    }
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  for (int i = (int)(0); i < (int)(q); ++i) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    vector<int> res = run(s.substr(l, r - l + 1));
    for (int i = (int)(0); i < (int)(res.size()); ++i) {
      if (i) {
        cout << ' ';
      }
      cout << res[i];
    }
    cout << endl;
  }
  return 0;
}
