UEFA Champions League Gym - 101778I

Statements

Conan is always busy investigating murders, and he rarely finds an opportunity to enjoy his time. His friend Ran told him that this lifestyle harms his health, and this may lead to premature death. So, Conan decided taking a break to enjoy his time.

At the night, Ran told Conan that he can enjoy by watching the UEFA Champions League matches. Conan does not know anything about this competition and its rules, so, Ran starts explaining to him what are the rules of the knockout stage that will start today.

In the knockout stage, two teams play two matches against each other, such that the first match will hold on first team's stadium and the second match will hold on second team's stadium. The winning team who will qualify for the next stage is the team who score more goals than its opponent. If the two teams score the same number of goals over the two matches, the team which scores more goals in the opponent stadium qualifies for the next stage. If this procedure does not produce a result (i.e. if both teams score the same number of goals at each other stadiums), two 15-minute periods of extra time are played at the end of the second match. (See notes for more clarification)

Ran is not sure if Conan understood her explanation or not, so she decides to give him a test. Ran will give Conan the results of two matches and he must determine the winner. Can you help Conan in his test so he can continue watching the match?

Input

The first line contains an integer T (1 ≤ T ≤ 500), in which T is the number of test cases.

Each test case consists of a line containing four integers a, b, c, and d (0 ≤ a, b, c, d ≤ 10), in which a is the number of goals the first team scored in the first match, b is the number of goals the second team scored in the first match, c is the number of goals the first team scored in the second match, and d is the number of goals the second team scored in the second match.

Output

For each test case, print a single line containing 1 if the first team won, 2 if the second team won, or  - 1 if the winner cannot be determined and the two teams will play an extra time.

Example

Input

3
1 2 4 1
4 0 1 6
2 0 0 2

Output

1
2
-1

AC代码(认真读题目)

Select Code

#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a, b, c, d, t;
    int sm, sm1;
    scanf("%d",&t);
        while(t--)
        {
            scanf("%d %d %d %d",&a, &b, &c, &d);
            sm = a+c;
            sm1 = b+d;
            if(sm>sm1)
                printf("1\n");
            else if(sm<sm1)
                printf("2\n");
            else if(sm==sm1)
              {
                 if(c>b)
                 printf("1\n");
                 else if(b>c)
                 printf("2\n");
                 else
                 printf("-1\n");
              }
        }

    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值