#include <bits/stdc++.h>
using namespace std;
int a;
int b;
string s;
int lef[100002] = {0}, righ[100002] = {0};
queue<int> q[100002];
int visit[100002] = {0};
int dikerjain[100002] = {0};
int bit[11][100002] = {0};
int res[100002][11] = {0};
void update(int idx, int start) {
  for (int i = start; i <= a; i += (i & -i)) {
    bit[idx][i]++;
  }
}
int query(int idx, int start) {
  int sum = 0;
  for (int i = start; i > 0; i -= (i & -i)) {
    sum += bit[idx][i];
  }
  return sum;
}
int main() {
  scanf("%d %d", &a, &b);
  cin >> s;
  s = "$" + s + "$";
  for (int i = 0; i < b; i++) {
    scanf("%d %d", &lef[i], &righ[i]);
    q[lef[i]].push(i);
  }
  for (int i = 0; i <= a; i++) {
    if (!visit[i]) {
      int temp = i;
      int dir = 1;
      int coun = 0;
      int tanda = -1;
      while (1) {
        visit[i] = 1;
        while (!q[temp].empty()) {
          int depan = q[temp].front();
          q[temp].pop();
          if (depan >= 0) {
            if (!dikerjain[depan]) {
              q[lef[depan] - 1].push(-depan - 1);
              q[righ[depan] + 1].push(-depan - 1);
              dikerjain[depan] = 1;
              coun++;
            }
          } else {
            depan = -depan - 1;
            if (dikerjain[depan]) {
              dikerjain[depan] = 0;
              for (int j = 0; j < 10; j++) {
                res[depan][j] +=
                    (query(j, righ[depan]) - query(j, lef[depan] - 1));
              }
              coun--;
            }
          }
        }
        if (coun == 0) break;
        if (s[temp] >= '0' && s[temp] <= '9') {
          update(s[temp] - '0', temp);
          if (s[temp] == '0')
            s[temp] = '$';
          else
            s[temp]--;
          tanda = -1;
        } else if (s[temp] == '>') {
          dir = 1;
          if (tanda >= 0) s[tanda] = '$';
          tanda = temp;
        } else if (s[temp] == '<') {
          dir = -1;
          if (tanda >= 0) s[tanda] = '$';
          tanda = temp;
        }
        temp += dir;
      }
    }
  }
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < 10; j++) {
      if (j) printf(" ");
      printf("%d", res[i][j]);
    }
    printf("\n");
  }
  return 0;
}
