#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, r, k;
  int q[5];
  cin >> t;
  for (int i = 0; i < t; i++) {
    k = 0;
    cin >> n >> r;
    for (int j = 0; j < n - 1; j++) {
      cin >> q[j];
      k = k + q[j];
    }
    cout << ((r - k) % n + n) % n + 1 << endl;
  }
  return 0;
}
