Can someone help me finish the below formula please. I am trying to put the formula in to Cell Y5. I

In Cell Z5 the number is 2, Cell AA5 the number is 0. So the correct answer to the formula would be Y. This only works if Z5 is higher than 0 and Cell AA5 is exactly zero.

In Cell Z6 the number is 0, Cell AA6 is number 0. So the correct answer to the formula would be N.

In Cell Z7 the number is 1, Cell AA7 is number 2. I would then want to look at Column AB7 and Cell AC7. The number in Cell AB7 is 7 and the number in Cell AC7 is 29. As the number in Cell AB7 is lower than AC7 I would like the answer to the formula to be Y.

In Cell Z8 the number is 1, Cell AA8 is number 1. I would then want to look at Column AB8 and Cell AC8. The number in Cell AB7 is 27 and the number in Cell AC7 is 9. As the number in Cell AC8 is lower than AB8 I would like the answer to the formula to be N.

In Cell Z9 the number is 3, Cell AA9 is number 2. I would then want to look at Column AB9 and Cell AC9. The number in Cell AB9 is 17 and the number in Cell AC9 is 9. As the number in Cell AC9 is lower than AB9 I would like the answer to the formula to be N.

Sorry for the long text, it's pretty late!

Thanks for any help!