#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long inf = 0x3f3f3f3f;   const long long llinf = 1e18;   const long long nax = 0;   int n, m;   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     cin >> n >> m;     vector<int> a(n + 5), b(m + 5);     int maks1 = 0, mins1 = inf, mins2 = inf;     for (int i = 0; i < n; ++i) {       cin >> a[i];       maks1 = max(maks1, a[i]);       mins1 = min(mins1, a[i]);     }     for (int i = 0; i < m; ++i) {       cin >> b[i];       mins2 = min(mins2, b[i]);     }     if (max(mins1 * 2, maks1) < mins2) {       cout << max(mins1 * 2, maks1) <<   n ;     } else       cout <<  -1  <<   n ;   }   