Problem: Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game...

Every zombie gets a number ni (1 ≤ ni ≤ N) written on his forehead. Although no zombie can see his own number, he can see the numbers written on the foreheads of all N - 1 fellows. Note that not all numbers have to be unique (they can even all be the same). From this point on, no more communication between zombies is allowed. Observation is the only key to success. When the cuckoo clock strikes midnight, all attendees have to simultaneously guess the number on their own forehead. If at least one of them guesses his number correctly, all zombies survive and go home happily. On the other hand, if not a single attendee manages to guess his number correctly, all of them are doomed to die!

Zombies aren't very bright creatures though, and Heidi has to act fast if she does not want to jeopardize her life. She has one single option: by performing some quick surgery on the brain she managed to get from the chest, she has the ability to remotely reprogram the decision-making strategy of all attendees for their upcoming midnight game! Can you suggest a sound strategy to Heidi which, given the rules of the game, ensures that at least one attendee will guess his own number correctly, for any possible sequence of numbers on the foreheads?

Given a zombie's rank R and the N - 1 numbers ni on the other attendees' foreheads, your program will have to return the number that the zombie of rank R shall guess. Those answers define your strategy, and we will check if it is flawless or not.

Input

The first line of input contains a single integer T (1 ≤ T ≤ 50000): the number of scenarios for which you have to make a guess.

The T scenarios follow, described on two lines each: 

  * The first line holds two integers, N (2 ≤ N ≤ 6), the number of attendees, and R (1 ≤ R ≤ N), the rank of the zombie who has to make the guess. 
  * The second line lists N - 1 integers: the numbers on the foreheads of all other attendees, listed in increasing order of the attendees' rank. (Every zombie knows the rank of every other zombie.) 

Output

For every scenario, output a single integer: the number that the zombie of rank R shall guess, based on the numbers ni on his N - 1 fellows' foreheads.

Examples

Input

4
2 1
1
2 2
1
2 1
2
2 2
2


Output

1
2
2
1


Input

2
5 2
2 2 2 2
6 4
3 2 6 1 2


Output

5
2

Note

For instance, if there were N = 2 two attendees, a successful strategy could be: 

  * The zombie of rank 1 always guesses the number he sees on the forehead of the zombie of rank 2. 
  * The zombie of rank 2 always guesses the opposite of the number he sees on the forehead of the zombie of rank 1. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T first, T second) {
  while (second > 0) {
    first %= second;
    swap(first, second);
  }
  return first;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class _T>
inline _T sqr(const _T &first) {
  return first * first;
}
template <class _T>
inline string tostr(const _T &a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795L;
template <typename T>
inline void input(T &a) {
  static int ed;
  a = 0;
  while (!isdigit(ed = getchar()) && ed != '-') {
  }
  char neg = 0;
  if (ed == '-') {
    neg = 1;
    ed = getchar();
  }
  while (isdigit(ed)) {
    a = 10 * a + ed - '0';
    ed = getchar();
  }
  if (neg) a = -a;
}
template <typename T = int>
inline T nxt() {
  T res;
  input(res);
  return res;
}
void myassert(bool v) { assert(v); }
mt19937 generator;
bool check(int v) {
  if (v < 2) return false;
  for (int i = 2; i * i <= v; ++i) {
    if (v % i == 0) {
      return false;
    }
  }
  return true;
}
long long pw(long long a, long long n, long long m) {
  long long res = 1;
  while (n) {
    if (n & 1ll) {
      res = res * a % m;
    }
    a = a * a % m;
    n >>= 1;
  }
  return res;
}
long long inv(long long a, long long p) {
  long long res = 1;
  while (a > 1) {
    res = res * (p - p / a) % p;
    a = p % a;
  }
  return res;
}
long long mod = 1000003;
struct M {
  long long a[101][101];
  M() { memset((a), 0, sizeof(a)); }
  static M E() {
    M res;
    for (int i = 0; i < (int)(101); ++i) res.a[i][i] = 1;
    return res;
  }
  M operator*(const M &r) const {
    M res;
    for (int i = 0; i < (int)(101); ++i)
      for (int j = 0; j < (int)(101); ++j) {
        for (int k = 0; k < (int)(101); ++k) res.a[i][j] += a[i][k] * r.a[k][j];
        res.a[i][j] %= mod;
      }
    return res;
  }
};
M pw(M first, int n) {
  M res = M::E();
  while (n) {
    if (n & 1) {
      res = res * first;
    }
    first = first * first;
    n >>= 1;
  }
  return res;
}
void solve(int test) {
  int n = nxt();
  int r = nxt() - 1;
  int s = 0;
  for (int i = 0; i < (int)(n - 1); ++i) s += nxt() - 1;
  s %= n;
  cout << (r - s + n) % n + 1 << "\n";
}
int main(int argc, char **argv) {
  int t = nxt();
  int c = 0;
  while (t--) {
    solve(++c);
  }
  return 0;
}