提示: 欢迎访问OurACM平台
Problem 1067 Running Length Code

Accept: 267    Submit: 468
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

The running length code is a kind of compression code of binary string. A running length code for a binary string is a sequence of bytes, where each byte (1 byte=8 bit) denotes a continuous part (continuous '0' or continuous '1') of the binary string, with the leftmost bit of the byte denoting the color of the part (0 or 1) and the other seven bits denoting the length of the part. Suppose that the length of any continuous part in a binary string is less than 128. Now given a binary string which length is less than 1000, write a program to encode it with the running length code.

Input

The input contains a series of test cases, and each case consists of two lines. The first line of each test case is a single integer n (1<=n<1000), representing the length of a binary string. The following line represents the binary string, with one space separating every two bits of the binary string. The last test case is followed by a line containing one 0 that terminates the input.

Output

Output one line for each test case, representing the running length code of the binary string. Each byte of the running length code is represented by an integer less than 255. Every two integers are separated by one space.

Sample Input

15 1 0 1 0 0 0 0 0 0 0 1 1 1 1 1 0

Sample Output

129 1 129 7 133

Source

FJNUPC 2005

Submit  Back  Status  Discuss