#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using ld = long double;
const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)1e3 + 3;
void solve() {
  ll n, a, b, c;
  cin >> n >> c >> a >> b;
  if (a > b) swap(a, b);
  cout << min(n - 1, b - a + c) << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(20);
  cout << fixed;
  ll t;
  cin >> t;
  while (t--) solve();
}
