Let $I = [0 , 1]$; let $Q = I \times I$. Define $f: Q \to \mathbb{R}$ by letting $f(x , y) = 1 /q$ if y is rational and $x = p/q$ Let $I = [0 , 1]$; let $Q = I \times I$. Define $f: Q \to \mathbb{R}$ by letting $f(x , y) = 1 /q$
if y is rational and $X = p/q$, where p and q are positive integers with no
common factor; let $f(x, y) = 0$ otherwise. 

I know that this question is already posted here P and here P, but I still do not understand what the answers say or convince me, I would like a clearer answer and for all the questions.
(a) How do I show that $\int_{Q}f$ exists? I have thought that this function is almost zero except in a set of zero measure but I do not know how to use this. One could show that this function is integrable considering cases on $x$ and $y$ as for example that both are rational or irrational? Could that be reduced to the case where $x$ and $y$ are rational? This function is not very similar to the Thomae function?
(b) I think that $\underline{\int_{y\in I}}f(x,y)=\sup\{L(f(x,y),P_B)\}$, where $L(f(x,y), P_B)=\sum_{R_B}m_{R_B}(f)v(R_B)$ and $R_B$ is a rectangle determined by the partition $P_B$ where $P=(P_A,P_B)$ and $P$ is a partition of $Q$. But we know that $\sum_{R_B}m_{R_B}(f)v(R_B)=0$ because in a very small interval we will always find an irrational and so $f(x,y)=0$, with which $\underline{\int_{y\in I}}f(x,y)=0$. I do not know how to calculate $\overline{\int_{y\in I}}f(x,y)$, could someone help me please? I think that $\overline{\int_{y\in I}}f(x,y)=\inf\{U(f(x,y),P_B)\}$, but in this case I do not know which one is $M_{R_B}(f)$.
(c) Fubini's theorem says that if $\int_{Q}f$ exists then $\int_{Q}f=\int_{x\in A}\underline{\int_{y\in I}}f(x,y)=\int_{x\in A}\overline{\int_{y\in I}}f(x,y)$, with which I have to calculate $\int_{x\in A}\underline{\int_{y\in I}}f(x,y)$ and $\int_{x\in A}\overline{\int_{y\in I}}f(x,y)$ and for this I need $\overline{\int_{y\in I}}f(x,y)$.
 A: Part (a)
We can show that, given any $\epsilon >0$, there is a partition $P$ of $Q=[0,1]^2$ such that $U(P,f) - L(P,f) < \epsilon$ and the integral exists by the Riemann criterion.
Let $P = P_A \times P_B$ be any partition and $R = R_A \times R_B$ any subrectangle.  The irrational numbers are dense.  Hence, we can always find an irrational $x \in R_A$ (as well as irrational $y \in R_B$). Consequently, there always exist points $(x,y) \in R$ where $f(x,y) = 0$. Since $0 \leqslant f(x,y) \leqslant 1$ everywhere, we have $\inf_R f(x,y) = 0$ for every $R$, and consequently $L(P,f) = 0$.
Given $\epsilon >0$, choose a positive integer $N > 2/\epsilon$ so that $1/N < \epsilon/2$. 
The set  $A_N = \{x \in \mathbb{Q} \cap [0,1]: x = p/q, (p,q) = 1, q \leqslant N \}$ is finite.  Here we have the rational numbers in $[0,1]$ where in lowest terms the denominator in $x = p/q$ is no bigger than $N$.  Let $m$ be the number of elements of $A_N$.
An upper sum can be split into a sum over subrectangles (1) including and (2) excluding points $(x,y)$ with $x \in A_N$:
$$U(P,f) = \sum_{(1)}M_j \, v(R_j) + \sum_{(1)}M_j \, v(R_j) $$
where $M_j$ is the supremum of $f$ over the subrectangle $R_j$.
For the first sum, there are at most $4m$ subrectangles $R_j$ including points where $f(x,y) = 1/q \geqslant 1/N$.  Choosing partition where the largest subrectangle has content less than $\epsilon/(8m)$,  we have 
$$\sum_{(1)} \leqslant 4m \cdot \sup_{Q}f(x,y) \cdot \sup_{R_j \in P}v(R_j) \leqslant 4m \cdot 1 \cdot \frac{\epsilon}{8m} = \frac{\epsilon}{2}$$
For the second sum, the subrectangles contain no points with $x \in A_N$. Thus $M_j \leqslant 1/N < \epsilon/2$ and 
$$\sum_{(2)} \leqslant \epsilon \sum_{(2)} v(R_j) < \frac{\epsilon}{2}.$$
Therefore, there is a partition $P$ such that $U(P,f) < \epsilon$ and since $L(P,f) = 0$ we have
$$U(P,f) - L(P,f) < \epsilon$$ 
proving that $f$ is Riemann integrable.
Furthermore, we have shown that $\int_{Q} f = 0$ since $\int_Q f = \underline{\int}_Q f = \sup_P L(P,f) = 0$.
Part (b)
If $x$ is irrational, then $f(x,y) = 0$ for a all $y \in I$ and, clearly,
$$\underline{\int}_{y \in I} f(x,y) = \overline{\int}_{y \in I} f(x,y)= 0.$$
On the other hand if $x = p/q$ in lowest terms, then $f(x,y) = 0$ if $y$ is irrational and $f(x,y) = 1/q$ if $y$ is rational. Again by density of the rationals we have for any partition $P_B$
$$L(P_B,f(x,\cdot)) = 0, \,\,\, U(P_B,f(x,\cdot)) = 1/q,$$
and, hence, 
$$\underline{\int}_{y \in I} f(x,y) = 0, \,\,\, \overline{\int}_{y \in I} f(x,y) = 1/q.$$
Part (c)
You should be able to finish this noting from part (b) that we have the Thomae function for
$$\overline{\int}_{y \in I}f(x,y) =  \begin{cases}1/q, \,\,\, x = p/q \\ 0, \quad \,\, x \text{ irrational} \end{cases}$$
