Rank of block matrix over $\mathbb{Q}$ and $\mathbb{F}_p$.

Let $M=\left[\begin{array}{c} A \\ B \end{array}\right]$ be a block matrix with integer entries. Let $p$ be a prime, and let $\mathbb{F}_p$ be the field with $p$ elements. Define $A_p, B_p,$ and $M_p$ be the matrices $A, B,$ and $M$ with entries reduced $\mod p$ respectively (considered as matrices with entries in $\mathbb{F}_p$). Let $\mathbb{Q}$ be the field of rational numbers.

Suppose that the rank of $A$ over $\mathbb{Q}$ is the same as the rank of $A_p$ over $\mathbb{F}_p$ and that the rank of $B$ over $\mathbb{Q}$ is the same as the rank of $B_p$ over $\mathbb{F}_p$. Is it true that the rank of $M$ over $\mathbb{Q}$ is the same as the rank of $M_p$ over $\mathbb{F}_p$? If it is false, how would one go about producing a counterexample?

$A= (2 \ 1)$ and $B=(4 \ 1)$ with $p=2$.
The rank of $A$ and $B$ is equal to $1$ on both $\mathbb Q$ and $\mathbb F_2$. However the rank of $M$ over $\mathbb Q$ is equal to $2$ and to $1$ over $\mathbb F_2$.