#include <bits/stdc++.h>
using namespace std;
int n, r;
void solve() {
  scanf("%d%d", &n, &r);
  int sum = 0;
  for (int i = (0), _for = (n - 1); i < _for; ++i) {
    int a;
    scanf("%d", &a);
    sum += a;
  }
  sum %= n;
  if ((r - sum + n) % n == 0)
    printf("%d\n", n);
  else
    printf("%d\n", (r - sum + n) % n);
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = (0), _for = (t); i < _for; ++i) solve();
  return 0;
}
