In poker, a hand with cards has two pairs if it contains two cards of one rank, two cards of a different rank, and a fifth card that does not match either of the first two ranks. (For example, the hand JJ774 has two pairs.) The order of the cards does not matter (so JJ774 and 7J74J are the same). How many hands with cards have two pairs? (All the cards are taken from a standard deck of cards.)