#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, x, k, sum = 0;
    scanf("%d%d", &n, &k);
    for (int i = 1; i < n; ++i) scanf("%d", &x), sum += x;
    for (int i = 1; i <= n; ++i) {
      if ((sum + i) % n == k - 1) {
        cout << i << endl;
        break;
      }
    }
  }
}
