each of the squares in a 2 x 2018 grid of squares is to be coloured black or white such that in any 2 x 2 block , at least one of the 4 squares is white. let P be the number of ways of colouring the grid. find the largest k so that $3^k$ divides P.
1. Define \( a_n \) as the number of ways to color a \( 2 \times n \) grid such that in any \( 2 \times 2 \) block, at least one of the four squares is white.
2. We establish the recurrence relation for \( a_n \) by considering the last column of the grid:
   - If the last column is not composed of two black squares, then the number of ways to color the first \( n-1 \) columns is \( a_{n-1} \).
   - If the last column is composed of two black squares, then the number of ways to color the first \( n-2 \) columns is \( a_{n-2} \).
   - Therefore, the recurrence relation is \( a_n = a_{n-1} + a_{n-2} \) for \( n \geq 3 \).

3. Determine the initial conditions:
   - For \( n = 1 \), there are 4 possible ways to color the \( 2 \times 1 \) grid: both squares white, top white and bottom black, top black and bottom white, both squares black. However, the last option is invalid as it violates the condition. Thus, \( a_1 = 4 \).
   - For \( n = 2 \), we need to count the valid colorings of a \( 2 \times 2 \) grid. There are 16 possible ways to color the grid, but we need to exclude the invalid configurations:
     - All four squares black (1 way).
     - Three squares black and one white (4 ways).
     - Two squares black and two squares white in a \( 2 \times 2 \) block (6 ways).
     - Two squares black and two squares white in a non-\( 2 \times 2 \) block (4 ways).
     - One square black and three squares white (1 way).
     - All four squares white (1 way).
     - Thus, \( a_2 = 15 \).

4. Define \( (b_{2k}, b_{2k+1}) = \left(\frac{a_{2k}}{3^k}, \frac{a_{2k+1}}{3^k}\right) \) for each \( k \in \mathbb{N} \).

5. Establish the recurrence relation for \( b_i \):
   - From the recurrence relation \( a_n = a_{n-1} + a_{n-2} \), we get:
     \[
     a_{2i+2} = a_{2i+1} + a_{2i}
     \]
     \[
     a_{2i+3} = a_{2i+2} + a_{2i+1}
     \]
   - Substituting the definitions of \( b_i \):
     \[
     b_{2i+2} = \frac{a_{2i+2}}{3^{i+1}} = \frac{a_{2i+1} + a_{2i}}{3^{i+1}} = \frac{a_{2i+1}}{3^{i+1}} + \frac{a_{2i}}{3^{i+1}} = b_i + b_{i+1}
     \]
     \[
     b_{2i+3} = \frac{a_{2i+3}}{3^{i+1}} = \frac{a_{2i+2} + a_{2i+1}}{3^{i+1}} = \frac{a_{2i+2}}{3^{i+1}} + \frac{a_{2i+1}}{3^{i+1}} = 3b_i + 4b_{i+1}
     \]

6. Analyze the sequence \( \{b_i\} \) modulo 9:
   - Compute the first few terms of \( b_i \) modulo 9:
     \[
     b_1 = 4, \quad b_2 = 5, \quad b_3 = 1, \quad b_4 = 6, \quad b_5 = 1, \quad b_6 = 7, \quad b_7 = 4, \quad b_8 = 2, \quad b_9 = 1, \quad b_{10} = 3, \quad b_{11} = 1, \quad b_{12} = 4, \quad b_{13} = 4, \quad b_{14} = 8, \quad b_{15} = 1, \quad b_{16} = 0, \quad b_{17} = 1, \quad b_{18} = 1
     \]
   - The sequence is periodic with period 18.

7. Determine \( b_{2018} \mod 9 \):
   - Since \( 2018 \equiv 2 \mod 18 \), we have \( b_{2018} \equiv b_2 \equiv 5 \mod 9 \).

8. Calculate \( a_{2018} \):
   - Using the definition, \( a_{2018} = 3^{1009} \cdot b_{2018} \).
   - Since \( b_{2018} \equiv 5 \mod 9 \), \( a_{2018} \) has a \( v_3 \) of \( 1009 \).

The final answer is \( \boxed{1009} \)