Decoding The Message

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Aliens connected with people and sent a message containing the answer to "The Ultimate Question of Life, the Universe, and Everything".

People received nn bytes (integers from 00 to 255255 inclusive). The decoding algorithm is the following:

  • Let us consider all n!n! permutations of received bytes.
  • Consider each permutation as a number written in base 256256. Numbers can be equal.
  • Multiply all these numbers modulo 65,53565\\,535.
  • The result is the decoded message!

For each byte ii, you are given the number c_ic\_i of received bytes ii. Please decode the message.

입력

The first line contains a single integer tt (1t1001 \leq t \leq 100) --- the number of test cases. Description of test cases follows.

The first line of each test case contains a single integer kk (1k2561 \leq k \leq 256) --- the number of bytes ii such that c_i0c\_i \neq 0.

Each of the next kk lines contains two integers ii, c_ic\_i (0i2550 \leq i \leq 255, 1c_i1091 \leq c\_i \leq 10^9). It is guaranteed that all given values ii are different.

For all other 256k256 - k bytes, the numbers c_ic\_i are equal to 00.

It is guaranteed that _i=0255c_i=n109\displaystyle \sum\limits\_{i=0}^{255} c\_i = n \leq 10^9.

출력

For each test case, print a single integer --- the decoded message.