How do I determine the values of n and q to be fed to lattice estimator from openFHE library?

For example, suppose I am running the example code advanced-ckks-bootstrapping.cpp and have set the value of ring dimension as 2^16 (parameters.SetRingDim(1<<16), is n=65536 in this case? Also, how can I determine q in this example? I see in this previous discussion how log q bits are generated. So, would the value of q to be fed to the estimator be 2^(number of log q elements printed), that is 2^40?

I am finding it very confusing to understand the difference in p,q and Q and set the values in lattice estimator. I see in this paper, the value of logq in the tables extend to 829 (table 2). So is q=2^829 and also is 829 the size of the moduli chain? How do I figure out the size of the moduli chain in this case?