How to determine Basis for Final K1

In 2022 I invested $40,000 in a startup.  The business lost money every year and I received the  Final K1 in 2024.  The distribution will be in 2025.
 
Two questions:
How do I calculate the Basis for 2024 for regular and AMT ?
TT asks for a number for Box 20, Code Z but there is more than one?  Which number does TT want?
 
See data from the K1's below:
 
L Partners Capital Account Analysis        2022    2023    2024
    Beginning Capital Account        40,000    27,094    17604
    Current Net income              -12,906    -9490    -11,790
    Withdrawals and Distributions                           1,082
    Ending Capital Account            27,094    17,604    4732
 
2024 k1 Part III
Box 1 Ordinary business income= -8,869
Box 2 Net rental real estate income = 240
Box 9a Net long term capital gain = 2,492
Box 10 Net section 1231 gain = -5,500
Box 13 Other deductions = 1
Box 14 Self employment earnings = 0
Box 17 AMT = 16
Box 18 C =172
Box 19 Distributions = 1082
Box 20 N = 8,869
Box 20 Z see below
 
Section 199A Information, Box 20, Code Z,     2022    2023    2024
 Ordinary Income                        -12,906    -9670    -8,869
W-2 Wages                               2,647      2,129    1,797
Unadjusted Basis of Assets                30,881    31,277
Note:  no info on Basis for 2024
 
Thanks for the help