  At the very foundation of the second law of thermodynamics lies the fact that
no heat engine operating between two reservoires of temperatures $T_C\leq T_H$
can overperform the ideal Carnot engine: $\langle W \rangle / \langle Q_H
\rangle \leq 1-T_C/T_H$. This inequality follows from an exact fluctuation
relation involving the nonequilibrium work $W$ and heat exchanged with the hot
bath $Q_H$. In a previous work [Sinitsyn N A, J. Phys. A: Math. Theor. {\bf 44}
(2011) 405001] this fluctuation relation was obtained under the assumption that
the heat engine undergoes a stochastic jump process. Here we provide the
general quantum derivation, and also extend it to the case of refrigerators, in
which case Carnot's statement reads: $\langle Q_C \rangle / |\langle W \rangle|
\leq (T_H/T_C-1)^{-1}$.
