#include using namespace std; typedef long long ll; template inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} //自作関数 template ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;} #define rep(i,n) for(ll i=0;i<(ll)n;i++) #define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++) long long INF = 1LL<<60; int n; int main(){ int x,m; cin>>x>>n>>m; vector a(n),b(m); rep(i,n)cin>>a[i]; rep(i,m)cin>>b[i]; bool mr,max; rep(i,n)if(a[i]==x){ mr=true; } rep(i,m)if(b[i]==x){ max=true; } if(!mr&&!max)cout<<-1<