#include <bits/stdc++.h>
using namespace std;
long long n, k, t, ans, a[1001000];
int main() {
  scanf("%lld", &t);
st:
  long long l1, r1, l2, r2;
  scanf("%lld %lld %lld %lld %lld %lld", &n, &k, &l1, &r1, &l2, &r2);
  long long d, work, intersec;
  intersec = max(0LL, min(r1, r2) - max(l1, l2));
  d = max(r1, r2) - min(l1, l2) - intersec;
  work = max(0LL, max(l1, l2) - min(r1, r2));
  ans = 0;
  k -= intersec * n;
  for (int i = 0; i < n && k > 0; i++) {
    if (i == 0 || (d > work && k > work)) {
      ans += work;
      long long tmp = min(k, d);
      ans += tmp;
      k -= tmp;
    } else {
      ans += 2LL * k;
      k = 0;
    }
  }
  if (k > 0) {
    ans += 2LL * k;
    k = 0;
  }
  printf("%lld\n", ans);
  if (--t) goto st;
  return 0;
}
