#include #define int long long using namespace std; string to_string(string s) { return s; } template string to_string(T v) { string res = "["; for (const auto &x : v) { res += to_string(x) + ", "; } res += "]"; return res; } void dbg_out() { cout << endl; } template void dbg_out(Head H, Tail... T) { cout << ' ' << to_string(H); dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif using ll = long long; using vi = vector; #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define all(v) (v).begin(), (v).end() #define sz(v) ((int)(v).size()) const int MAX_DISHES = 1e4; int Main[MAX_DISHES]; int App[MAX_DISHES]; int nbDishes; void Read() { cin >> nbDishes; for (int i = 0; i < nbDishes; i ++) { cin >> Main[i]; } for (int i = 0; i < nbDishes; i ++) { cin >> App[i]; } sort(Main, Main + nbDishes); sort(App, App + nbDishes); int ans = 0; for (int cut = 0; cut < nbDishes; cut ++) { int cur = 1LL << 60; for (int i = 0; i < nbDishes; i ++) { int other = (i + cut) % nbDishes; cur = min(cur, abs(Main[i] - App[other])); } ans = max(ans, cur); } cout << ans << endl; return; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int nbTests; cin >> nbTests; for (int i = 0; i < nbTests; i ++) { Read(); } return 0; }