SP1793 GEN2 - Text Generater II

Description

[HL](http://www.spoj.com/users/g201513), [HJ](http://www.spoj.com/users/lcosvse) and [FGD](http://www.spoj.com/users/xilinx) set problem for [ZMY](http://www.spoj.com/users/zmy) everyday. The title of each problem bores them very much. The title is a string which consists only lower case letters. It's length is _L_, and, of course, the title must contain their names(hl, hj, fgd) as consecutive substrings.More apparently, _N_ evil consecutive substrings should not appear in the title. Any string satisfying the two conditions above is OK. The task ZMY is to do today is: if they give ZMY 8 problems every week, and the title of each problem should not be repeated, how many (complete) weeks can they set problems?

Input Format

Multiple test cases.Input terminates by EOF. For each test case: The first line contains two space-seperated integers L(0

Output Format

For each test case output one line contains the answer modudo 1000.