A $30\times30$ table is given. We want to color some of it's unit squares such that any colored square has at most $k$ neighbors. ( Two squares $(i,j)$ and $(x,y)$ are called neighbors if $i-x,j-y\equiv0,-1,1 \pmod {30}$ and $(i,j)\neq(x,y)$. Therefore, each square has exactly $8$ neighbors) 
What is the maximum possible number of colored squares if$:$

$a) k=6$

$b)k=1$
### Part (a): Maximum number of colored squares if \( k = 6 \)

1. **Define Variables:**
   Let \( n \) be the number of non-colored squares. Therefore, the number of colored squares is \( 900 - n \) since the table is \( 30 \times 30 \).

2. **Count Ordered Pairs:**
   Consider all ordered pairs of neighboring squares consisting of one colored square and one non-colored square. Each non-colored square can be part of at most 8 such ordered pairs, so there are at most \( 8n \) such pairs.

3. **Minimum Pairs for Colored Squares:**
   Each colored square must be part of at least 2 such ordered pairs (since \( k = 6 \), each colored square can have at most 6 colored neighbors, leaving at least 2 non-colored neighbors). Therefore, there are at least \( 2(900 - n) \) such pairs.

4. **Set Up Inequality:**
   \[
   8n \geq 2(900 - n)
   \]

5. **Solve Inequality:**
   \[
   8n \geq 1800 - 2n
   \]
   \[
   10n \geq 1800
   \]
   \[
   n \geq 180
   \]

6. **Conclusion:**
   The number of colored squares is at most \( 900 - 180 = 720 \).

7. **Achievability:**
   This can be achieved by coloring a square \((i, j)\) if \( 5 \nmid 2i - j \).

### Part (b): Maximum number of colored squares if \( k = 1 \)

1. **Connected Components:**
   All connected components of colored squares consist of a single square or a domino (a pair of adjacent squares).

2. **Expand Colored Squares:**
   Consider expanding all colored unit squares and dominoes by 1 unit on the bottom and the left. This transforms them into \( 2 \times 2 \) and \( 2 \times 3 \) rectangles on the torus.

3. **Non-overlapping Condition:**
   The original condition of no two colored squares or dominoes touching by edge or corner translates to no two expanded rectangles overlapping.

4. **Maximize Placement:**
   We need to maximize \( 2A + B \), where \( A \) is the number of \( 2 \times 3 \) rectangles and \( B \) is the number of \( 2 \times 2 \) squares placed on the \( 30 \times 30 \) torus without overlapping.

5. **Area Constraint:**
   The total area covered by these rectangles must satisfy:
   \[
   6A + 4B \leq 900
   \]

6. **Maximize Expression:**
   We want to maximize:
   \[
   2A + B
   \]
   Using the area constraint:
   \[
   2A + B = \frac{6A + 4B}{3} - \frac{B}{3} \leq \frac{6A + 4B}{3} = 300
   \]

7. **Achievability:**
   This maximum value of 300 is achievable by coloring all squares with \( 2 \nmid i \) and \( 3 \nmid j \).

The final answer is \( \boxed{720} \) for part (a) and \( \boxed{300} \) for part (b).