$trump
$ns
$ew
def play(cards, first)
    suit = cards[first].suit
    winner = cards[first]
    cards.each do |c|
        if c.suit == $trump && winner.suit == $trump
            winner = c if c.rank > winner.rank
        elsif c.suit == $trump && winner.suit != $trump
            winner = c
        elsif c.suit == suit && winner.suit == suit
            winner = c if c.rank > winner.rank
        end
    end
    id = cards.index(winner)
    if id == 0 || id == 2
        $ns += 1
    else
        $ew += 1
    end
    return id
end
class Cards
    attr_accessor :suit, :rank
    def initialize(s)
        @rank = s[0].gsub((/T|J|Q|K|A/), "T" => "10", "J" => "11", "Q" => "12", "K" => "13", "A" => "14").to_i
        @suit = s[1]
    end
    def to_s
        "#{@rank} of #{@suit}"
    end
    def win?(c)
        if self.suit == $trump && c.suit != $trump
            return self
        elsif self.suit != $trump && c.suit == $trump
            return c
        elsif self.suit == $cur_suit && c.suit != $cur_suit
            return self
        elsif self.suit != $cur_suit && c.suit == $cur_suit
            return c
        elsif self.rank > c.rank
            return self
        else
            return c
        end
    end
end
loop do
    $trump = gets.chomp
    break if $trump == "\#"
    p = 4.times.map{gets.split.map{|e| Cards.new(e)}}
    $ns = $ew = 0
    first = 0
    13.times do |i|
        first = play([p[0][i],p[1][i],p[2][i],p[3][i]], first)
    end
    puts $ns > 6 ? "NS #{$ns - 6}" : "EW #{$ew - 6}"
end