Given triangle $ABC$, let $M$ be the midpoint of side $AB$ and $N$ be the midpoint of side $AC$. A circle is inscribed inside quadrilateral $NMBC$, tangent to all four sides, and that circle touches $MN$ at point $X.$ The circle inscribed  in triangle $AMN$ touches $MN$ at point $Y$, with $Y$ between $X$ and $N$. If $XY=1$ and $BC=12$, find, with proof, the lengths of the sides $AB$ and $AC$.
1. **Labeling Points of Tangency:**
   - Let \( P \) and \( R \) be the points of tangency of the incircle of \(\triangle AMN\) with \(AN\) and \(AM\) respectively. Since \(AP = AR\), let \(AP = AR = a\).
   - Let \(Y\) be the point where the incircle of \(\triangle AMN\) touches \(MN\). Since \(MR = MY\), let \(MR = MY = b\).
   - Let \(NP = NY\). Since \(XY = 1\), let \(NP = NY = c + 1\) and \(NL = c\), where \(L\) is the point of tangency of the larger circle on \(AC\).

2. **Tangency Points for Larger Circle:**
   - Let \(Q\) be the point of tangency of the larger circle on \(BC\). Since \(CL = CQ\), let \(CL = CQ = d\).
   - Let \(T\) be the point of tangency of the larger circle on \(AB\). Since \(MT = b + 1\) and \(TB = QB\), let \(TB = QB = e\).

3. **Equations from Tangency:**
   - Since \(AN = NC\), we have:
     \[
     a + c + 1 = c + d \implies a + 1 = d
     \]
     Therefore, \(d = a + 1\).

   - Since \(AM = MB\), we have:
     \[
     a + b = b + 1 + e \implies e = a - 1
     \]
     Therefore, \(e = a - 1\).

4. **Using \(BC = 12\):**
   - Since \(BC = 12\), we have:
     \[
     d + e = 12 \implies (a + 1) + (a - 1) = 12 \implies 2a = 12 \implies a = 6
     \]

5. **Substituting \(a = 6\):**
   - Now, substituting \(a = 6\):
     \[
     d = a + 1 = 6 + 1 = 7
     \]
     \[
     e = a - 1 = 6 - 1 = 5
     \]

6. **Finding \(c\) and \(b\):**
   - Since \(AL = AT\), we have \(b = c\).

7. **Proportionality in Similar Triangles:**
   - Since \(\triangle ANM\) is similar to \(\triangle ACB\), we have:
     \[
     \frac{2c + 1}{12} = \frac{6 + c}{12 + 2c}
     \]

8. **Solving the Proportion:**
   - Cross-multiplying the proportion:
     \[
     (2c + 1)(12 + 2c) = 12(6 + c)
     \]
     \[
     24c + 2c^2 + 12 + 2c = 72 + 12c
     \]
     \[
     2c^2 + 12c + 12 = 72
     \]
     \[
     2c^2 + 12c - 60 = 0
     \]
     \[
     c^2 + 6c - 30 = 0
     \]

9. **Solving the Quadratic Equation:**
   - Using the quadratic formula \(c = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\):
     \[
     c = \frac{-6 \pm \sqrt{6^2 - 4 \cdot 1 \cdot (-30)}}{2 \cdot 1}
     \]
     \[
     c = \frac{-6 \pm \sqrt{36 + 120}}{2}
     \]
     \[
     c = \frac{-6 \pm \sqrt{156}}{2}
     \]
     \[
     c = \frac{-6 \pm 2\sqrt{39}}{2}
     \]
     \[
     c = -3 \pm \sqrt{39}
     \]

10. **Selecting the Positive Root:**
    - Since \(c\) must be positive:
      \[
      c = -3 + \sqrt{39}
      \]

11. **Calculating Side Lengths:**
    - \(AB = 2a = 2 \times 6 = 12\)
    - \(AC = 2c + 1 = 2(-3 + \sqrt{39}) + 1 = -6 + 2\sqrt{39} + 1 = -5 + 2\sqrt{39}\)

The final answer is \( \boxed{ AB = 12 } \) and \(AC = -5 + 2\sqrt{39}\)