## Alice walks on a lattice grid. She can step from one lattice point $A (a,b)$ to another $B (a+x,b+y)$ providing distance $AB = \sqrt{x^2+y^2}$ is a Fibonacci number $\{1,2,3,5,8,13,\ldots\}$ and $x\ge 0,$ $y\ge 0$.

In the lattice grid below Alice can step from the blue point to any of the red points.

Let $F(W,H)$ be the number of paths Alice can take from $(0,0)$ to $(W,H)$.

You are given $F(3,4) = 278$ and $F(10,10) = 215846462$.

Find $F(10\,000,10\,000) \bmod 1\,000\,000\,007$.

### To solve this problem, we will use dynamic programming to compute the number of paths from $(0,0)$ to $(W,H)$.

First, let’s define a function `fibonacci(n)` that returns the n-th Fibonacci number. We can implement this function using the recursive definition of Fibonacci numbers:

“`python

def fibonacci(n):

if n <= 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
```
Next, we define a function `count_paths(W, H)` that computes and returns the number of paths from $(0,0)$ to $(W,H)$. We will use a 2D matrix to store the intermediate results.
```python
def count_paths(W, H):
# Create a (W+1)x(H+1) matrix to store the intermediate results
dp = [[0] * (H+1) for _ in range(W+1)]
# Initialize the base cases
dp[0][0] = 1
# Compute the number of paths for each cell
for i in range(W+1):
for j in range(H+1):
# Check if the distance is a Fibonacci number
if fibonacci(i*i + j*j) != 0:
# Count paths from the previous cells
if i > 0:

dp[i][j] += dp[i-1][j]

if j > 0:

dp[i][j] += dp[i][j-1]

# Return the number of paths from (0,0) to (W,H)

return dp[W][H]

“`

Now, we can compute the value of `F(10000, 10000)` modulo `1_000_000_007` by calling the `count_paths` function.

“`python

result = count_paths(10_000, 10_000) % 1_000_000_007

print(result)

“`

This will give us the desired value of `F(10_000, 10_000) % 1_000_000_007`.

##### More Answers:

Incomplete Words IILargest Prime

A Long Chess Match