#include using namespace std; int main() { cin.tie(nullptr); cout.tie(nullptr); iostream::sync_with_stdio(false); int t; cin >> t; while (t--) { int n; cin >> n; vector as(n), bs(n); for (int i = 0; i < n; ++i) { cin >> as[i]; } for (int i = 0; i < n; ++i) { cin >> bs[i]; } sort(as.begin(), as.end()); sort(bs.begin(), bs.end()); int max_ans = 0; for (int shift = 0; shift < n; ++shift) { int cur = INT_MAX; for (int j = 0; j < n; ++j) { cur = min(cur, abs(as[j] - bs[(j + shift) % n])); } max_ans = max(max_ans, cur); } cout << max_ans << '\n'; } }