What can be said about $A$ and $B$ given the exact sequence $0 \to R^p \to A \to R^r \to R^q \to B \to 0$? Let $A,B$ be two $R$-modules over a commutative ring $R$ (restrict to $R = \mathbb{Z}$ or $R= \mathbb{K}$ a field where appropriate). Suppose $A$ and $B$ fit into an exact sequence   
$0 \to R^p \to A \to R^r \to R^q \to B \to 0$
for integers $p,q,r > 0$, where $R^{n} = R \oplus R ... \oplus R$ ($n$-times). Then what can be said about $A$ and $B$? Specifically,
1) Are there any cases where $A$ and $B$ be computed (most generally in terms of $p,q,r$)?
If not 
2) Given an allowed $B$ what can be said about $A$?
3) Given an allowed $A$ what can be said about $B$?
 A: Assume $R$ is a PID.
Clearly, there is a short exact sequence $0\to M_2\to A\to M_1\to 0$, where $M_1\subset R^r$ is the image of the map $A\to R^r$, so a free module of rank $d\le r$, and $M_2\cong R^p$ is the kernel of that map. There are no extensions between free modules, so $A$ is free of rank $p+d$. 
Furthermore, there is an exact sequence $0\to M_3\to M_4\to B\to 0$, where $M_3\subset R^q$ is the kernel of the map $R^q\to B$, and $M_4\cong R^q$. Note that due to exactness $M_3$ is the same as the image of the map $R^r\to R^q$, which is the quotient of $R^r$ by $M_1$; thus, it is a free module of rank $r-d$. Therefore, modulo torsion $B$ is free of rank $q-r+d$; however, unlike $A$, $B$ might have torsion. (Consider the case $A=R^p$, the map $R^p\to A$ being the identity, the map $A\to R^r$ being zero, then the rest $0\to R^r\to R^q\to B\to 0$ is just a presentation of the most general finitely generated $B$ by generators and relations.) 
If you only fix modules in the exact sequence but don't have information on maps, this probably is as much as you can establish.
