Hi there, I have been studying the following set (in order to investigate the average of products of Ramanujan sums with some weights):
$$ A=\lbrace (n,m) \in \mathbb{Z}/q\mathbb{Z} \times \mathbb{Z}/q\mathbb{Z} \mid \text{ }nm\equiv a \mod{q},\text{ } n \equiv 1 \mod{d_{1}}, \text{ } m \equiv 1 \mod{d_{2}} \rbrace $$
where $q$ is any positive integer, $d_{1}$ and $d_{2}$ are proper divisors of $q$ and $(a,q)=1$.
For the case $a=1$, using a bit algebra I have deduced the elementary formula
$$\sum_{\substack{n_{1}n_{2}\equiv 1\mod{q}, \\\ n_{1} \equiv 1 \mod{d_{1}}, \\\ n_{2} \equiv 1 \mod{d_{2}}}}=\frac{\phi(q)}{\mathrm{lcm}(\phi(d_{1}),\phi(d_{2}))}.$$
Is it possible to derive a formula for $|A|$?