#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:667772160")
using namespace std;
struct __isoff {
  __isoff() {
    if (0) freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
    srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
  }
  ~__isoff() {}
} __osafwf;
const unsigned long long p1 = 31;
const unsigned long long p2 = 29;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int infi = 1e9 + 7;
const long long inf = 1e18 + 7;
const long long dd = 7e5 + 7;
const long long mod = 1e9 + 7;
const long long mod2 = 1e6 + 3;
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    int n, r;
    cin >> n >> r;
    r--;
    int sum = 0;
    for (long long i = 0; i < (long long)n; i++) {
      if (i != r) {
        int t;
        cin >> t;
        sum += t - 1;
      }
    }
    sum %= n;
    cout << (r - sum + n) % n + 1 << '\n';
  }
}
