Problem: There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts.

  * Current character pointer (CP); 
  * Direction pointer (DP) which can point left or right; 



Initially CP points to the leftmost character of the sequence and DP points to the right.

We repeat the following steps until the first moment that CP points to somewhere outside the sequence.

  * If CP is pointing to a digit the interpreter prints that digit then CP moves one step according to the direction of DP. After that the value of the printed digit in the sequence decreases by one. If the printed digit was 0 then it cannot be decreased therefore it's erased from the sequence and the length of the sequence decreases by one. 
  * If CP is pointing to "<" or ">" then the direction of DP changes to "left" or "right" correspondingly. Then CP moves one step according to DP. If the new character that CP is pointing to is "<" or ">" then the previous character will be erased from the sequence. 



If at any moment the CP goes outside of the sequence the execution is terminated.

It's obvious the every program in this language terminates after some steps.

We have a sequence s1, s2, ..., sn of "<", ">" and digits. You should answer q queries. Each query gives you l and r and asks how many of each digit will be printed if we run the sequence sl, sl + 1, ..., sr as an independent program in this language.

Input

The first line of input contains two integers n and q (1 ≤ n, q ≤ 105) — represents the length of the sequence s and the number of queries. 

The second line contains s, a sequence of "<", ">" and digits (0..9) written from left to right. Note, that the characters of s are not separated with spaces. 

The next q lines each contains two integers li and ri (1 ≤ li ≤ ri ≤ n) — the i-th query.

Output

For each query print 10 space separated integers: x0, x1, ..., x9 where xi equals the number of times the interpreter prints i while running the corresponding program. Print answers to the queries in the order they are given in input.

Examples

Input

7 4
1&gt;3&gt;22&lt;
1 3
4 7
7 7
1 7


Output

0 1 0 1 0 0 0 0 0 0
2 2 2 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
2 3 2 1 0 0 0 0 0 0

Solution (in PYTHON):

Solution:
#!/usr/bin/env python 
# -*- coding: utf-8 -*- 

def lang (program):
  ans = [0,0,0,0,0,0,0,0,0,0]
  ip  = {'cp':0, 'dp':'>'}

  while 0 <= ip['cp'] < len(program):
    flag = 0

    if ('0' <= program[ip['cp']]) & (program[ip['cp']] <= '9'):
      i = int(program[ip['cp']])
      ans[i] += 1

      if i == 0:
        del program[ip['cp']]
        flag = 1
      else: program[ip['cp']] = str(i-1)
        
    elif (program[ip['cp']] == '>') | (program[ip['cp']] == '<'):
      ip['dp'] = program[ip['cp']]

      shift = ip['cp'] + ((1) if (ip['dp'] == '>') else (-1))
      if ( 0 > shift ) | ( shift >= len(program) ): break

      if (program[shift] == '>') | (program[shift] == '<'):
        if (ip['dp'] == '>'): flag = 1
        del program[ip['cp']]
    
    if   ip['dp'] == '>': 
      if not flag: ip['cp'] += 1
    elif ip['dp'] == '<':
      ip['cp'] -= 1

    # print ' '.join(program) # debug it
  return ans

def simple_strip_programming ():
  # head
  # print "\n\t��������� ������� ��������� ����������������".decode('cp1251')

  # first string
  n,_,q = raw_input().partition(' ')
  n = int (n); q = int (q)
  # checking input data
  if (n <  1) or (q > 100): return -1 # error!

  # second string
  program = list ( raw_input () )
  # checking input data
  if ( len(program) != n ): return -1 # error!

  l_ = [0 for i in range (0,q)]
  r_ = [0 for i in range (0,q)]
  ans= [0 for i in range (0,q)]
  # third,..,(q+2)-th string
  for i in range (0,q):
    l,_,r  = raw_input().partition(' ')
    l_[i]  = int (l)-1
    r_[i]  = int (r)
    # checking input data
    if (r_[i] < l_[i]) or ((l_[i] < 0) | (l_[i] >= n)) or ((r_[i] > n) | (r_[i] < 0)): return -1 # error!

  for i in range (0,q):
    par    = program[l_[i]:r_[i]]
    ans[i] = lang (par)
    # ans[i-1] ~ [0,x,y,0,0,0,0,0,z,0]

  # output answer
  for i in range (0,q):
    ans[i] = map(str,ans[i])
    print ' '.join(ans[i])

  return

simple_strip_programming  ()