#include<iostream>
using namespace std;
int main() {
int iterations, size;
int diff = 0;
int* a;
int* b;
cin >> iterations >> size;
a = new int[size];
b = new int[size];
for (int i = 0; i < iterations; i++) {
for (int j = 0; j < 2; j++) {
for (int k = 0; k < size; k++) {
if (j == 0) {
cin >> a[k];
}
else {
cin >> b[k];
if (a[k]-b[k] < diff) {
diff = a[k] - b[k];
}
}
}
}
cout << diff * -1 << endl;
}
return 0;
}