#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
inline bool mina(A &x, const B &y) {
  return (y < x) ? (x = y, 1) : 0;
}
template <class A, class B>
inline bool maxa(A &x, const B &y) {
  return (x < y) ? (x = y, 1) : 0;
}
int main() {
  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  };
  int T;
  cin >> T;
  for (int _n = (T); _n--;) {
    int N, R;
    cin >> N >> R;
    int sum = 0;
    int j = 0;
    for (int _n = (N - 1); _n--;) {
      int a;
      cin >> a;
      ++j;
      j += j == R;
      sum += j - a;
    }
    cout << ((sum - 1) % N + N) % N + 1 << '\n';
  }
  return 0;
}
