Little Petya very much likes strings. Recently he has received a voucher to purchase a string as a gift from his mother. The string can be bought in the local shop. One can consider that the shop has all sorts of strings over the alphabet of fixed size. The size of the alphabet is equal to *k*. However, the voucher has a string type limitation: specifically, the voucher can be used to purchase string *s* if the length of string's longest substring that is also its weak subsequence (see the definition given below) equals *w*.

String *a* with the length of *n* is considered the weak subsequence of the string *s* with the length of *m*, if there exists such a set of indexes 1 ≤ *i*<sub class="lower-index">1</sub> &lt; *i*<sub class="lower-index">2</sub> &lt; ... &lt; *i*<sub class="lower-index">*n*</sub> ≤ *m*, that has the following two properties: 
 -  *a*<sub class="lower-index">*k*</sub> = *s*<sub class="lower-index">*i*<sub class="lower-index">*k*</sub></sub> for all *k* from 1 to *n*; -  there exists at least one such *k* (1 ≤ *k* &lt; *n*), for which *i*<sub class="lower-index">*k* + 1</sub> – *i*<sub class="lower-index">*k*</sub> &gt; 1. 
Petya got interested how many different strings are available for him to purchase in the shop. As the number of strings can be very large, please find it modulo 1000000007 (10<sup class="upper-index">9</sup> + 7). If there are infinitely many such strings, print "-1".
The first line contains two integers *k* (1 ≤ *k* ≤ 10<sup class="upper-index">6</sup>) and *w* (2 ≤ *w* ≤ 10<sup class="upper-index">9</sup>) — the alphabet size and the required length of the maximum substring that also is the weak subsequence, correspondingly.
2 2
10
3 5
1593
2 139
717248223
5 6
983725
1000 1002
9396758
131 132
757914194
4 4
4912
3 2
57
1 1000000000
1
666 888888888
424798470
1000000 1000000000
600002237
1000000 1000000
438349146
1000000 2
739181318
2 1000000000
851562506
1000000 500000
53435433
12345 543210123
290786804
1 2
1
1 3
1
1 4
1
1 5
1
1 6
1
1 7
1
1 8
1
2 3
20
2 4
40
2 5
80
2 6
160
2 7
320
2 8
640
3 3
177
3 4
531
3 6
4779
3 7
14337
3 8
43011
4 2
292
4 3
1216
4 5
19648
4 6
78592
4 7
314368
4 8
1257472
5 2
1585
5 3
7745
5 4
39205
5 5
196745
5 7
4918625
5 8
24593125
6 2
9726
6 3
50916
6 4
296856
6 5
1789776
6 6
10755936
6 7
64535616
6 8
387213696
7 2
68425
7 3
366625
7 4
2290855
7 5
15673105
7 6
109953655
7 7
770280385
7 8
391962660
8 2
547912
8 3
2953952
8 4
18951136
8 5
138867968
8 6
92073977
8 7
746268616
8 8
999179293
999999 1000001
134450642
1000000 1000001
142931557
1000000 999999
250496915
1000000 999998
129080538
1000000 999997
769225275
1000000 1000002
555999483
1000000 1000003
479108007
983039 939524096
604697498
998999 3
356230103
987899 555555
229752266
999009 55
484803676
999009 818243
282452206
999009 999004
614735788
999009 999005
945978791
999009 999006
175954096
999009 999007
318397869
999009 999008
751039945
999009 999009
187298386
999010 72
131671481
999010 808035
568832480
999010 999005
898095114
999010 999006
100649860
999010 999007
292072410
999010 999008
253072162
999010 999009
808216351
999010 999010
493965177
999011 64
197612280
999011 133617
471490419
999011 999006
537424009
999011 999007
932469897
999011 999008
712314569
999011 999009
272668831
999011 999010
926206743
999011 999011
68819519
print("_RANDOM_GUESS_1693680671.7460253")# 1693680671.7460415