#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
const long long N = 200100;
long long L[10], R[10];
long long n, k;
bool ok(long long t, long long inicio, long long ini, long long dist) {
  long long have = inicio;
  long long best = have;
  long long cur = have;
  for (long long qtd = 1; qtd <= n; qtd++) {
    if (t < dist) break;
    t -= dist;
    long long mn = min(L[0], L[1]);
    long long mx = max(R[0], R[1]);
    long long put = min(t, mx - mn - max(0LL, ini));
    cur += put;
    t -= put;
    best = max(best, cur + (t / 2));
  }
  if (best >= k) return 1;
  return 0;
}
void solve() {
  cin >> n >> k;
  for (long long i = 0; i < 2; i++) {
    cin >> L[i] >> R[i];
  }
  if (pair<long long, long long>(L[0], R[0]) >
      pair<long long, long long>(L[1], R[1])) {
    swap(L[0], L[1]);
    swap(R[0], R[1]);
  }
  long long l = 0, r = 1e18;
  long long ans = 1e18;
  long long inicio = 0;
  long long esq = max(L[0], L[1]);
  long long dir = min(R[0], R[1]);
  if (esq <= dir) {
    inicio = 1ll * n * (dir - esq);
  }
  long long dist = 0;
  if (esq <= dir) {
    dist = 0;
  } else {
    assert(L[1] > R[0]);
    dist = L[1] - R[0];
  }
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (ok(mid, inicio, (dir - esq), dist)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
