#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, N, R, sum, temp;
  cin >> T;
  int ans[T];
  for (int i = 0; i < T; i++) {
    cin >> N >> R;
    sum = 0;
    for (int j = 0; j < N - 1; j++) {
      cin >> temp;
      sum += temp;
    }
    sum = sum % N;
    ans[i] = (N + R - sum) % N + 1;
  }
  for (int i = 0; i < T; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
