Preheat oven to 425 degrees.
In a large bowl, mix the ricotta, mascarpone and egg together until combined. Season with salt and pepper (to taste).
In the pan you plan to use (I used a rectangular, tall cake tin that you would use to make banana bread), start by adding a layer of the ricotta/mascarpone, followed by pesto, a handful of mozzarella cheese and finally a layer of pasta. Repeat until you run out of pasta sheets. Top it with mozzarella cheese and cover with aluminum foil.
Bake for 35 minutes then remove the foil and turn the broiler on and cook for about 5 minutes or until the top is golden brown. Take out of the oven and let sit for about 5-10 minutes before cutting into it and serving.