Score a hand of Hearts Hearts is a trick-taking card game for 4 players. Each trick is taken by the player who played the highest card of the leading suit. At the end of each hand, the players incur a penalty score depending on the penalty cards they have taken; the task is to determine the scores under Microsoft Hearts rules.

Input

Input is 4 lists (or delimited string, array, etc.) showing the penalty cards taken by each of the 4 players. The penalty cards are

2♥, 3♥, 4♥, 5♥, 6♥, 7♥, 8♥, 9♥, 10♥, J♥, Q♥, K♥, A♥, Q♠


which we shall represent as

2,  3,  4,   5,  6,  7,  8,  9,  10,  11, 12,  13,  1,  0


respectively.

Output

Output is the 4 penalty points incurred by the 4 players (list, string, array etc.). Scoring is as follows:


Each heart (♥, represented by integers 1 to 13 inclusive) incurs 1 point
The queen of spades (Q♠, represented by 0) incurs 13 points
Exception: if a player has taken all of the penalty cards (called shooting the moon), then he incurs 0 points, while all other players incur 26 points.


Test cases

[2, 8, 7, 1], [3, 4], [], [9, 5, 6, 0, 10, 11, 12, 13]     --&gt;  4,  2,  0, 20
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [], [], [1]   --&gt; 25,  0,  0,  1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0], [], [], [] --&gt;  0, 26, 26, 26


Shortest code in bytes wins.
R, 85 77 74 bytes

function(x,z=sapply(x,function(x)sum(x&gt;0)+any(x&lt;1)*13))abs(z-any(z&gt;25)*26)


Unnamed function that takes an R-list as input. Works by counting the number of elements &gt;0 and adds 13 if any element within each vector is &lt;1 (i.e. queen of spades) and store as z.

If any element in z is &gt;25, return 26-z, else return z.

Try it on R-fiddle