Imagine an infinitely long pencil standing between two infinitely tall walls, like this, but the pencil and the walls extend infinitely upward.

| | | |

| | | |

| | | |

| | | |

| \ / |

If the pencil leans to the left or right at all, it would have to break through the walls, but it can't. Therefore, the pencil must stand completely upright on it's tip parallel to the walls. How can the walls force the pencil to stand completely upright when there is no contact between the pencil and the walls at all? I have looked for an answer and searched, and as far as I know there is nothing online about this. Can somebody explain?