Problem:
Card Game

Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card.
The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each.

Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.

Input

In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.

Constraints

n ≤ 1000

The length of the string ≤ 100

Output

Print the final scores of Taro and Hanako respectively. Put a single space character between them.

Sample Input

3
cat dog
fish fish
lion tiger

Sample Output

1 7

Solution in C# (judge verdict: Accepted)

using System;
class Program
{
    static void Main()
    {
        Manipulation manip = new Manipulation();
        const int CARDS = 1000;
        const int ARRAYER = 1;
        const int INIT = 0;
        string[] alpha;
        int delta = int.Parse(Console.ReadLine());

        char[] taroHArr;
        char[] hanaArr;
        int[] taroCard = new int[CARDS];
        int[] hanaCard = new int[CARDS];
        int taroP = 0;
        int hanaP = 0;
        int shor;
        int lon;

        for (int i = INIT; i < delta; i++)
        {
            alpha = Console.ReadLine().Split(' ');
            taroHArr = alpha[0].ToCharArray();
            hanaArr = alpha[1].ToCharArray();
            int Tcount = taroHArr.Length;
            int Hcount = hanaArr.Length;
            for (int j = INIT; j < Tcount; j++)
            {
                taroCard[j] = taroHArr[j];
            }
            for (int j = INIT; j < Hcount; j++)
            {
                hanaCard[j] = hanaArr[j];
            }

            if (Hcount < Tcount)
            {
                shor = Hcount;
                lon = Tcount;
            }
            else if (Tcount < Hcount)
            {
                shor = Tcount;
                lon = Hcount;
            }
            else
            {
                shor = Hcount;
                lon = INIT;
            }

            for (int j = INIT; j < shor; ++j)
            {
                int moveck1 = hanaP;
                int moveck2 = taroP;

                if (taroCard[j] == hanaCard[j] && j == shor - ARRAYER)
                {
                    hanaP += manip.SameNumsCk(lon, Hcount, Tcount);
                    taroP += manip.SameNumsCk(lon, Tcount, Hcount);
                }
                //manip.Moveck(moveck1, hanaP); <--これをやりたいがやり方がわからない
                if (moveck1 != hanaP || moveck2 != taroP)
                {
                    break;
                }
                hanaP += manip.Dictionary(hanaCard[j], taroCard[j]);
                if (moveck1 != hanaP || moveck2 != taroP)
                {
                    break;
                }
                taroP += manip.Dictionary(taroCard[j], hanaCard[j]);
                if (moveck1 != hanaP || moveck2 != taroP)
                {
                    break;
                }
            }
        }
        Console.WriteLine("{0} {1}", taroP, hanaP);
    }
    class Manipulation
    {
        const int LOSE = 0;
        const int WIN = 3;
        const int DRAW = 1;
        internal int Dictionary(int WinnerCard, int LoserCard)
        {
            if (LoserCard < WinnerCard)
                return WIN;
            else
                return LOSE;

        }
        internal int SameNumsCk(int long1, int WinnerCount, int LoserCount)
        {
            if (long1 == WinnerCount)
                return WIN;
            else if (WinnerCount == LoserCount)
                return DRAW;
            else
                return LOSE;
        }
        //internal string MoveCk(int PrevPt,int NowPt)
        //{
        //    if (PrevPt != NowPt)
        //        return break;
        //    else
        //        return "";
        //}
    }
}