Gambling Nim

As you know, the game of “Nim” is played with n piles of stones, where the i-th pile initially contains a i stones. Two players alternate the turns. During a turn a player picks any non-empty pile and removes any positive number of stones from it. The one who is not able to make a move loses the game.

Petya and Vasya are tired of playing Nim, so they invented their own version of the game and named it the “Gambling Nim”. They have n two-sided cards, one side of the i-th card has number a i written on it, while the other side has number b i. At the beginning of the game the players put all the cards on the table, each card only one of its sides up, and this side is chosen independently and uniformly. Thus they obtain a sequence c 1, c 2, …, c n, where c i is equal to a i or b i. Then they take n piles of stones, with i-th pile containing exactly c i stones and play Nim. Petya takes the first turn.

Given that both players play optimally, find the probability of Petya’s victory. Output the answer as an irreducible fraction.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 500 000) — the number of cards in the deck.

Each of the following n lines contains the description of one card, consisting of two integers a i and b i (0 ≤ a i, b i ≤ 1018).

Output

Output the answer as an irreducible fraction p / q. If the probability of Petya’s victory is 0, print 0/1.

Examples

input

2
1 1
1 1

output

0/1

input

2
1 2
1 2

output

1/2

input

3
0 4
1 5
2 3

output

1/1

Solution:

#include <bits/stdc++.h>

using namespace std;

void get(long long &v) {
char ch = getchar();
while (ch < '0' || ch > '9') {
ch = getchar();
}
v = 0;
while ('0' <= ch && ch <= '9') {
    v = v * 10 + ch - '0';
    ch = getchar();
  }
}

const int N = 1000010;

long long A[N], B[N];

int main() {
  int n;
  scanf("%d", &n);
  long long u = 0;
  for (int i = 0; i < n; i++) {
    get(A[i]);
    get(B[i]);
    u ^= A[i];
    B[i] ^= A[i];
  }
  long long g = 0;
  int r = 0;
  for (int bit = 61; bit >= 0; bit--) {
for (int i = r; i < n; i++) {
      if (B[i] & (1LL << bit)) {
        swap(B[i], B[r]);
        break;
      }
    }
    if (!(B[r] & (1LL << bit))) {
      continue;
    }
    if ((g & (1LL << bit)) != (u & (1LL << bit))) {
      g ^= B[r];
    }
    for (int i = r + 1; i < n; i++) {
      if (B[i] & (1LL << bit)) {
        B[i] ^= B[r];
      }
    }
    r++;
  }
  if (g != u) {
    puts("1/1");
    return 0;
  }
  cout << ((1LL << r) - 1) << "/" << (1LL << r) << endl;
  return 0;
}