
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Given an ellipse $M: \frac{x^2}{a^2} + \frac{y^2}{b^2} = 1 (a > b > 0)$ with eccentricity $\frac{1}{2}$, the distance from the right focus to the line $x= \frac{a^2}{c}$ is $3$, and the equation of circle $N$ is $(x-c)^2+y^2=a^2+c^2$ (where $c$ is the semi-focal distance),
$(1)$ find the equation of ellipse $M$ and the equation of circle $N$.
$(2)$ If the line $l: y=kx+m$ is the common tangent line of ellipse $M$ and circle $N$, find the equation of line $l$.

Present the answer in LaTex format: \boxed{Your answer}
user