The Hypercube Hotel is a strange new mathematically themed hotel, a competitor to Hilbert's Hotel. The hotel as an unusual way of numbering its rooms. Each room has an digit number so that the -th digit (from the left) is between 1 and . Conversely, every number in this form has a corresponding room. Room numbers are unique.

Two different rooms are called **neighbours** if for every , the -th digit of the two room numbers differ by at most 1. For example, the rooms with numbers 213 and 222 are neighbours but the rooms with numbers 111 and 131 are not neighbours. A room is not a neighbour of itself.

All the rooms in the hotel are occupied, so each room generates a certain amount of noise. If a room has number call this quantity . For each room, the **noise level** of that room is the sum of the amounts of noise generated by its neighbours. Given the amount of noise generated by each room, find the noise level of each room.

#### Constraints

Subtask | Points | Additional Constraints |
---|---|---|

1 | 5 | |

2 | 5 | |

3 | 5 | |

4 | 15 | |

5 | 70 | None |

#### Input Specification

The first line contains the integer .

The next line contains integers .

The next lines each contain a single integer . The lines are given in increasing order of the room number .

#### Output Specification

For each room, output a line containing a single integer, the noise level of that room. Do this in increasing order of room number.

#### Sample Input

```
2
2 3
1
2
3
4
5
6
```

#### Sample Output

```
11
19
13
8
16
10
```

## Comments

I think the memory restriction is a bit too strict on java submissions

Java can pass. Mem complexity is and time complexity is

Will there be an editorial for this question?

The original draft of my editorial has suffered a tragic accident, so the editorial will unfortunately be delayed. I plan to write something up soon, though. Edit: the editorial is up now.

Could you provide some high level ideas, if not editorial? Thanks

here's some idea ryx might be interested. Note this is idea only, so please don't delete this post.