#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int t;
  scanf("%d", &t);
  for (int akf = 0; akf < t; akf++) {
    int n, r;
    scanf("%d %d", &n, &r);
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
      int x;
      scanf("%d", &x);
      sum += x;
    }
    sum = sum % n;
    sum = (n + r - sum) % n;
    if (sum == 0) sum = n;
    printf("%d\n", sum);
  }
}
