Dividing Strings
题号:NC209527
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

With powerful decision-making skills, ZYB can solve complex problems

ZYB has a decimal string of length . He wants to split the string into several (at least 2) non-empty continuous substrings and minimize the difference between the maximum value and the minimum value of the gifts. The value of a continuous substring is the value of it when it's considered as a decimal number. 
For instance, when the string '1230' is split into '12' and '30', the values of the two parts are 12 and 30 separately. Notice that the substrings are not allowed to contain leading zero(s). For example, the only feasible way of splitting '001' is '0', '0' and '1'. 

Can you help ZYB find the fairest splitting?

输入描述:

There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:
The first line contains an integer (), indicating the length of the decimal string.
The second line contains a decimal string of length .( for each ).
It is guaranteed that the sum of in all test cases does not exceed .

输出描述:

For each test case, output one line containing the minimum difference between the maximum value and the minimum value.
示例1

输入

复制
4
2
08
5
10199
7
9710296
8
12341234

输出

复制
8
2
6
0