  Given a prime $p$, an integer $H\in[1,p)$, and an arbitrary set $\cal
M\subseteq \mathbb F_p^*$, where $\mathbb F_p$ is the finite field with $p$
elements, let $J(H,\cal M)$ denote the number of solutions to the congruence $$
xm\equiv yn\bmod p $$ for which $x,y\in[1,H]$ and $m,n\in\cal M$. In this
paper, we bound $J(H,\cal M)$ in terms of $p$, $H$ and the cardinality of $\cal
M$. In a wide range of parameters, this bound is optimal. We give two
applications of this bound: to new estimates of trilinear character sums and to
bilinear sums with Kloosterman sums, complementing some recent results of
Kowalski, Michel and Sawin (2018).
