#include #include "testlib.h" using namespace std; int main() { long long N, M; N = inf.readLong((long long)1, (long long)1000, "N"); inf.readSpace(); M = inf.readLong((long long)1, (long long)1000, "M"); inf.readEoln(); vector X(N), Y(M); for (int i = 0; i < N; i++) { if (i != 0) inf.readSpace(); X[i] = inf.readLong((long long)1, (long long)1000000000, "X"); } inf.readEoln(); for (int i = 0; i < M; i++) { if (i != 0) inf.readSpace(); Y[i] = inf.readLong((long long)1, (long long)1000000000, "Y"); } inf.readEoln(); inf.readEof(); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i != j && X[i] == X[j]) cout << -1 << endl; } } for (int i = 0; i < M; i++) { for (int j = 0; j < M; j++) { if (i != j && Y[i] == Y[j]) cout << -1 << endl; } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (X[i] == Y[j]) cout << -1 << endl; } } for (int i = 0; i < N; i++) { long long min_ = 1LL << 60; for (int j = 0; j < M; j++) { if (X[i] < Y[j]) min_ = min(min_, Y[j] - X[i]); } if (min_ != 1LL << 60) cout << min_ << endl; else cout << "Infinity" << endl; } }