CF1148F.Foo Fighters

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given nn objects. Each object has two integer properties: valival_i — its price — and maskimask_i . It is guaranteed that the sum of all prices is initially non-zero.

You want to select a positive integer ss . All objects will be modified after that. The ii -th object will be modified using the following procedure:

  • Consider maskimask_i and ss in binary notation,
  • Compute the bitwise AND of ss and maskimask_i ( s&maskis \,\&\, mask_i ),
  • If ( s&maskis \,\&\, mask_i ) contains an odd number of ones, replace the valival_i with vali-val_i . Otherwise do nothing with the ii -th object.

You need to find such an integer ss that when the modification above is done the sum of all prices changes sign (if it was negative, it should become positive, and vice-versa; it is not allowed for it to become zero). The absolute value of the sum can be arbitrary.

输入格式

The first line contains a single integer nn ( 1n31051 \leq n \leq 3 \cdot 10^5 ) — the number of objects.

The ii -th of next nn lines contains integers valival_i and maskimask_i ( 109vali109-10^9 \leq val_i \leq 10^9 , 1maski26211 \le mask_i \le 2^{62} - 1 ) — the price of the object and its mask.

It is guaranteed that the sum of valival_i is initially non-zero.

输出格式

Print an integer ss ( 1s26211 \le s \le 2^{62} - 1 ), such that if we modify the objects as described above, the sign of the sum of valival_i changes its sign.

If there are multiple such ss , print any of them. One can show that there is always at least one valid ss .

输入输出样例

  • 输入#1

    5
    17 206
    -6 117
    -2 151
    9 93
    6 117
    

    输出#1

    64
    
  • 输入#2

    1
    1 1
    

    输出#2

    1
    

说明/提示

In the first test sample all objects will change their prices except for the object with mask 151151 .

So their total sum will change its sign: initially 2424 , after modifications — 28-28 .

In the second test sample the only object will change its price. So the total sum will change its sign.

首页