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 JAVA (judge verdict: Accepted)

import java.util.Scanner;
 
enum Type{
    SAME,
    A_BIG,
    B_BIG
};
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        int N = scanner.nextInt();
        String TARO,HANAKO;
        int score_TARO = 0,score_HANAKO = 0;
 
        for(int loop = 0; loop < N; loop++){
 
            TARO = scanner.next();
            HANAKO = scanner.next();
 
            switch(compString(TARO,HANAKO)){
            case SAME:
                score_TARO += 1;
                score_HANAKO += 1;
                break;
            case A_BIG:
                score_TARO += 3;
                break;
            case B_BIG:
                score_HANAKO += 3;
                break;
            }
        }
 
        System.out.printf("%d %d\n", score_TARO,score_HANAKO);
    }
 
    //A基準で比較する関数
    public static Type compString(String A,String B){
        int a_index = 0,b_index = 0;
 
        while(a_index < A.length() && b_index < B.length() && A.charAt(a_index) == B.charAt(b_index)){
            a_index++;
            b_index++;
        }
 
        if(a_index < A.length() && b_index < B.length()){
            if(A.charAt(a_index) > B.charAt(b_index)){
                return Type.A_BIG;
            }else{
                return Type.B_BIG;
            }
 
        }else if(a_index < A.length() && b_index == B.length()){
            return Type.A_BIG;
        }else if(a_index == A.length() && b_index < B.length()){
            return Type.B_BIG;
        }else{
            return Type.SAME;
        }
    }
}