   #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define f first
    #define s second
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N = 200005;
    int mod = 1e9 + 7;

    vector<int> parent;
    vector<int> sz;
    vector<int> vis;

    void make_set(int s)
    {
      parent[s] = s;
      sz[s] = 1;
    }
    int find_set(int s)
    {
      if(s == parent[s])
      {
        return s;
      }
      return parent[s] = find_set(parent[s]);
    }
    void merge(int a,int b)
    {
      a = find_set(a);
      b = find_set(b);
      if(a != b)
      {
        if(sz[a] < sz[b])
        {
          swap(a,b);
        }
        sz[a] += sz[b];
        parent[b] = a;
      }
    }
  int32_t main()
  {
    IOS
       #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
      #endif

      int n,m;

      cin >> n >> m;

      parent.resize(n+1);
      vis.resize(n+1);
      sz.resize(n+1);

      for(int i = 1; i <= n; i++)
      {
        make_set(i);
      }
      for(int i = 1; i <= m; i++)
      {
        int x, y;
        cin >> x >> y;
        merge(x,y);
      }

      int ans = 0;

      for(int i = 1; i <= n; i++)
      {
        int p = find_set(i);
        if(!vis[p])
        {
          ans ++;
          vis[p] = true;
        }
      }
      ans= (1LL << (n - ans));
      cout << ans << endl;

    return 0;
  }


   #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define f first
    #define s second
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N = 200005;
    int mod = 1e9 + 7;

    vector<int> parent;
    vector<int> sz;
    vector<int> vis;

    void make_set(int s)
    {
      parent[s] = s;
      sz[s] = 1;
    }
    int find_set(int s)
    {
      if(s == parent[s])
      {
        return s;
      }
      return parent[s] = find_set(parent[s]);
    }
    void merge(int a,int b)
    {
      a = find_set(a);
      b = find_set(b);
      if(a != b)
      {
        if(sz[a] < sz[b])
        {
          swap(a,b);
        }
        sz[a] += sz[b];
        parent[b] = a;
      }
    }
  int32_t main()
  {
    IOS
       #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
      #endif

      int n,m;

      cin >> n >> m;

      parent.resize(n+1);
      vis.resize(n+1);
      sz.resize(n+1);

      for(int i = 1; i <= n; i++)
      {
        make_set(i);
      }
      for(int i = 1; i <= m; i++)
      {
        int x, y;
        cin >> x >> y;
        merge(x,y);
      }

      int ans = 0;

      for(int i = 1; i <= n; i++)
      {
        int p = find_set(i);
        if(!vis[p])
        {
          ans += (1 << (sz[p]-1));
          vis[p] = true;
        }
      }

      cout << ans << endl;

    return 0;
  }


  //Keep Working Hard
  // I__Like__Food
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp>
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  #define N 200005
  #define INF 1000000000000000

int n,m;

int parent[55];
int sz[55];
bool vis[55];

void init()
{
  for(int i = 1; i <= n; i++)
  {
    parent[i] = i;
    sz[i] = 1;
  }
}
int getParent(int s)
{
  if(s == parent[s])return s;
  else return parent[s] = getParent(parent[s]);
}
void join(int a,int b)
{
  a = getParent(a);
  b = getParent(b);
  if(a != b)
  {
    if(sz[a] < sz[b])
    {
      swap(a,b);
    }

    sz[a] += sz[b];
    sz[b] = 0;
    parent[b] = a;
  }
}

int32_t main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    cin >> n >> m;

    init();

    for(int i = 1; i <= m; i++)
    {
      int x, y;
      cin >> x >> y;
      join(x,y);
    }

    int ans = 0;

    for(int i = 1; i <= n; i++)
    {
      int p = getParent(i);
      if(!vis[p])
      {
        ans++;
        vis[p] = true;
      }
    }

    cout << (1LL << (n-ans));

  return 0;
}


#include<iostream>
#include<math.h>
#include<vector>

using namespace std;

const int mx = 55;
int vis[mx];
vector<int> adj[mx];

void dfs ( int u )
{
    vis[u] = 1;
    for ( auto v : adj[u] )
    {
        if ( vis[v]==0 )
            dfs ( v );
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m;
    cin >> n >> m;
    for ( int i = 1; i <= m; i++ )
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back( v );
        adj[v].push_back( u );
    }

    int cnt = 0;

    for( int i=1; i<=n; i++)
    {
        if( vis [i]==0)
        {
            dfs(i);
            cnt++;
        }
    }

    long long ans= pow(2.0, (n-cnt));

    cout << ans << endl;

    return 0;
}


#include<iostream>
#include<math.h>
#include<vector>

using namespace std;

const int mx = 55;
int vis[mx];
vector<int> adj[mx];

void dfs ( int u )
{
    vis[u] = 1;
    for ( auto v : adj[u] )
    {
        if ( vis[v]==0 )
            dfs ( v );
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m;
    cin >> n >> m;
    for ( int i = 1; i <= m; i++ )
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back( v );
        adj[v].push_back( u );
    }

    int cnt = 0;

    for( int i=1; i<=n; i++)
    {
        if( vis [i]==0)
        {
            dfs(i);
            cnt++;
        }
    }

    n= pow(2.0, (n-cnt));

    cout << n << endl;

    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

const int mx = 55;
int vis[mx];
vector<int> adj[mx];

void dfs ( int u )
{
    vis[u] = 1;
    for ( auto v : adj[u] )
    {
        if ( vis[v]==0 )
            dfs ( v );
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m;
    cin >> n >> m;
    for ( int i = 1; i <= m; i++ )
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back( v );
        adj[v].push_back( u );
    }

    int cnt = 0;

    for( int i=1; i<=n; i++)
    {
        if( vis [i]==0)
        {
            dfs(i);
            cnt++;
        }
    }

    n= pow(2.0, (n-cnt));
    cout << n << endl;

    return 0;
}


#include<iostream>
#include<math.h>
#include<vector>
//#include<algorithm>

using namespace std;

const int mx = 55;
int vis[mx];
vector<int> adj[mx];

void dfs ( int u )
{
    vis[u] = 1;
    for ( auto v : adj[u] )
    {
        if ( vis[v]==0 )
            dfs ( v );
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m;
    cin >> n >> m;
    for ( int i = 1; i <= m; i++ )
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back( v );
        adj[v].push_back( u );
    }

    int cnt = 0;

    for( int i=1; i<=n; i++)
    {
        if( vis [i]==0)
        {
            dfs(i);
            cnt++;
        }
    }

    cout << pow(2.0, (n-cnt)) << endl;

    return 0;
}


#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

const int mx = 55;
int vis[mx];
vector<int> adj[mx];

void dfs ( int u )
{
    vis[u] = 1;
    for ( auto v : adj[u] )
    {
        if ( vis[v]==0 )
            dfs ( v );
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, m;
    cin >> n >> m;
    for ( int i = 1; i <= m; i++ )
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back( v );
        adj[v].push_back( u );
    }

    int cnt = 0;

    for( int i=1; i<=n; i++)
    {
        if( vis [i]==0)
        {
            dfs(i);
            cnt++;
        }
    }

    cout << pow(2.0, (n-cnt)) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std ;

vector <int> nei[100100] ;
bool vis[100100] ;
long long ans ;

int DFS( int x ) {

	ans *= 2 ;
	vis[x] = 1  ;

	for ( int i = 0 ; i < nei[x].size() ; i++ )
		if ( !vis[nei[x][i]] )
		DFS(nei[x][i]) ;

	return ans/2 ;
}

int main () {

	int n , m ;

	cin >> n >> m ;

	while( m-- ) {

		int u , v ;

		cin >> u >> v ;

		nei[u].push_back(v) ;
		nei[v].push_back(u) ;

	}

	long long answer = 1 ;

	for ( int i = 0 ; i < n ; i++ ) {
		if ( !vis[i] ) {
		answer *= DFS(i) ;
		ans = 1 ;
	}
}

		cout << answer ;

}


import java.util.*;
public class FishWeights
{
   public static void main2 (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;
      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {
            aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      if ( flag)
      {
         System.out.println ("YES");
         return;
      }
      System.out.println (a +"\n" + b);
      System.out.println (aw +"\n" + bw);

      String r = "";
      if (a>b)
      r = "YES";
      else if (a == b)
      {
         if ( aw >= bw ) r = "YES";
         else r = "NO";
      }
      else
      {
         if ( aw > bw ) r = "YES";
         else if ( aw == bw ) r = "YES";
         else r = "NO";
      }

       System.out.println (r);
//       else System.out.println ("NO");
   }
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int n = sc.nextInt(), m = sc.nextInt(), i, k = sc.nextInt();
      int []a = new int[n];
      // a[0] = sc.nextInt();
//       for (i = 1; i < n; i++)
//       {
//          int j;
//          int temp = sc.nextInt();
//          for ( j = i-1; j>=0 && a[j]>temp; j--)
//          {
//             a[j+1] = a[j];
//          }
//          a[j+1] = temp;
//       }
//
//
//       int []b = new int[m];
//       b[0] = sc.nextInt();
//       for (i = 1; i < m; i++)
//       {
//          int j;
//          int temp = sc.nextInt();
//          for ( j = i-1; j>=0 && b[j]>temp; j--)
//          {
//             b[j+1] = b[j];
//          }
//          b[j+1] = temp;
//       }

      for ( i = 0; i < n; i ++)
      {
         a[i] = sc.nextInt();
      }
      int []b = new int[m];
      for ( i = 0; i < m; i ++)
      {
         b[i] = sc.nextInt();
      }

      if ( n > m)
      {
         System.out.println ("YES");
         return;
      }
      Arrays.sort(a);
      Arrays.sort(b);

      int j = m-1;
      i = n-1;
      while (j!=0 && i !=0 && b[j] >= a[i])
      {
         i--; j--;
      }
      if (i!=0 && (j == 0|| a[i]>b[j]))
         System.out.println ( "YES" );
      else
         System.out.println ("NO");
   }
}


import java.util.*;
public class FishWeights
{
   public static void main2 (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;
      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {
            aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      if ( flag)
      {
         System.out.println ("YES");
         return;
      }
      System.out.println (a +"\n" + b);
      System.out.println (aw +"\n" + bw);

      String r = "";
      if (a>b)
      r = "YES";
      else if (a == b)
      {
         if ( aw >= bw ) r = "YES";
         else r = "NO";
      }
      else
      {
         if ( aw > bw ) r = "YES";
         else if ( aw == bw ) r = "YES";
         else r = "NO";
      }

       System.out.println (r);
//       else System.out.println ("NO");
   }
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int n = sc.nextInt(), m = sc.nextInt(), i, k = sc.nextInt();
      int []a = new int[n];

      for ( i = 0; i < n; i ++)
      {
         a[i] = sc.nextInt();
      }
      int []b = new int[m];
      for ( i = 0; i < m; i ++)
      {
         b[i] = sc.nextInt();
      }

      if ( n > m)
       {
          System.out.println ("YES");
          return;
       }
      Arrays.sort(a);
      Arrays.sort(b);

      int j = m-1;
      i = n-1;
      boolean flag = true;
      while (j!=0 && i !=0 && flag)
      {
         if (b[j]>=a[i])
         {
            i--; j--;
         }
         else
         {
            flag = false;
            System.out.println("YES");
            break;
         }

      }
      if ( !flag ) return;
      if ( a[i] > b[j]) System.out.println("YES");
      else if (i == 0) System.out.println ( "NO" );
      else System.out.println("YES");
   }
}


import java.util.*;
public class FishWeights
{
   public static void main2 (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;
      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {
            aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      if ( flag)
      {
         System.out.println ("YES");
         return;
      }
      System.out.println (a +"\n" + b);
      System.out.println (aw +"\n" + bw);

      String r = "";
      if (a>b)
      r = "YES";
      else if (a == b)
      {
         if ( aw >= bw ) r = "YES";
         else r = "NO";
      }
      else
      {
         if ( aw > bw ) r = "YES";
         else if ( aw == bw ) r = "YES";
         else r = "NO";
      }

       System.out.println (r);
//       else System.out.println ("NO");
   }
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int n = sc.nextInt(), m = sc.nextInt(), i, k = sc.nextInt();
      int []a = new int[n];
      // a[0] = sc.nextInt();
//       for (i = 1; i < n; i++)
//       {
//          int j;
//          int temp = sc.nextInt();
//          for ( j = i-1; j>=0 && a[j]>temp; j--)
//          {
//             a[j+1] = a[j];
//          }
//          a[j+1] = temp;
//       }
//
//
//       int []b = new int[m];
//       b[0] = sc.nextInt();
//       for (i = 1; i < m; i++)
//       {
//          int j;
//          int temp = sc.nextInt();
//          for ( j = i-1; j>=0 && b[j]>temp; j--)
//          {
//             b[j+1] = b[j];
//          }
//          b[j+1] = temp;
//       }

      for ( i = 0; i < n; i ++)
      {
         a[i] = sc.nextInt();
      }
      int []b = new int[m];
      for ( i = 0; i < m; i ++)
      {
         b[i] = sc.nextInt();
      }

      // if ( n > m)
//       {
//          System.out.println ("YES");
//          return;
//       }
      Arrays.sort(a);
      Arrays.sort(b);

      int j = m-1;
      i = n-1;
      while (j!=0 && i !=0 && b[j] >= a[i])
      {
         i--; j--;
      }
      if (i!=0 && (j == 0 || a[i]>b[j]))
         System.out.println ( "YES" );
      else if (i == 0 && a[i]>b[i])
         System.out.println ("YES");
      else
         System.out.println ("NO");

   }
}


import java.util.*;
public class FishWeights
{
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt(); if (temp>max) max = temp;
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();
         if (temp>=max){
            max = temp;
              flag = false;
          }

         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;

      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {   aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      if ( flag)
      {
         System.out.println ("YES");
         return;
      }
      //System.out.println (aw +"\n" + bw);

      // if (aw>bw&&a>b) System.out.println ("YES");
//       else if ( aw>bw&&a<b) System.out.println ("YES");
//       else if ( aw<bw&&a>b) System.out.println ("YES");
//       else if ( aw<bw&&a<b)System.out.println ("NO");
//       else if ( a == b)
//       {
//          if (aw >= bw) System.out.println ("YES");
//          else System.out.println("NO");
//       }
//       else if (aw == bw)
//       {
//          if (a>=b) System.out.println ("YES");
//          else System.out.println ("NO");
//       }
      // String r = "";
//       if (aw>bw || a>b) r = "YES";
//       else r ="NO";
      String r = "";
      if (a>b)
      r = "YES";
      else if ( aw*1.0/a > bw*1.0/b) r = "YES";
      else r = "NO";

       System.out.println (r);
//       else System.out.println ("NO");
   }
}


import java.util.*;
public class FishWeights
{
   public static void main2 (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;
      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {
            aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      if ( flag)
      {
         System.out.println ("YES");
         return;
      }
      System.out.println (a +"\n" + b);
      System.out.println (aw +"\n" + bw);

      String r = "";
      if (a>b)
      r = "YES";
      else if (a == b)
      {
         if ( aw >= bw ) r = "YES";
         else r = "NO";
      }
      else
      {
         if ( aw > bw ) r = "YES";
         else if ( aw == bw ) r = "YES";
         else r = "NO";
      }

       System.out.println (r);
//       else System.out.println ("NO");
   }
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int n = sc.nextInt(), m = sc.nextInt(), i, k = sc.nextInt();
      int []a = new int[n];
      // a[0] = sc.nextInt();
//       for (i = 1; i < n; i++)
//       {
//          int j;
//          int temp = sc.nextInt();
//          for ( j = i-1; j>=0 && a[j]>temp; j--)
//          {
//             a[j+1] = a[j];
//          }
//          a[j+1] = temp;
//       }
//
//
//       int []b = new int[m];
//       b[0] = sc.nextInt();
//       for (i = 1; i < m; i++)
//       {
//          int j;
//          int temp = sc.nextInt();
//          for ( j = i-1; j>=0 && b[j]>temp; j--)
//          {
//             b[j+1] = b[j];
//          }
//          b[j+1] = temp;
//       }

      for ( i = 0; i < n; i ++)
      {
         a[i] = sc.nextInt();
      }
      int []b = new int[m];
      for ( i = 0; i < m; i ++)
      {
         b[i] = sc.nextInt();
      }
      Arrays.sort(a);
      Arrays.sort(b);

      int j = m-1;
      i = n-1;
      while (j!=0 && i !=0 && b[j] >= a[i])
      {
         i--; j--;
      }
      if (i!=0 && (j == 0|| a[i]>b[j]))
         System.out.println ( "YES" );
      else
         System.out.println ("NO");
   }
}


import java.util.*;
public class FishWeights
{
   public static void main2 (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;
      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {
            aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      if ( flag)
      {
         System.out.println ("YES");
         return;
      }
      System.out.println (a +"\n" + b);
      System.out.println (aw +"\n" + bw);

      String r = "";
      if (a>b)
      r = "YES";
      else if (a == b)
      {
         if ( aw >= bw ) r = "YES";
         else r = "NO";
      }
      else
      {
         if ( aw > bw ) r = "YES";
         else if ( aw == bw ) r = "YES";
         else r = "NO";
      }

       System.out.println (r);
//       else System.out.println ("NO");
   }
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int n = sc.nextInt(), m = sc.nextInt(), i, k = sc.nextInt();
      int []a = new int[n];
      a[0] = sc.nextInt();
      for (i = 1; i < n; i++)
      {
         int j;
         int temp = sc.nextInt();
         for ( j = i-1; j>=0 && a[j]>temp; j--)
         {
            a[j+1] = a[j];
         }
         a[j+1] = temp;
      }

      int []b = new int[m];
      b[0] = sc.nextInt();
      for (i = 1; i < m; i++)
      {
         int j;
         int temp = sc.nextInt();
         for ( j = i-1; j>=0 && b[j]>temp; j--)
         {
            b[j+1] = b[j];
         }
         b[j+1] = temp;
      }
      //Arrays.sort(a);
      //Arrays.sort(b);

      int j = m-1;
      i = n-1;
      while (j!=0 && i !=0 && b[j] > a[i])
      {
         i--; j--;
      }
      if (i!=0 && (j == 0|| a[i]>b[j]))
         System.out.println ( "YES" );
      else
         System.out.println ("NO");
   }
}


import java.util.*;
public class FishWeights
{
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt();
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();

         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;

      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {
            aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      // if ( flag)
//       {
//          System.out.println ("YES");
//          return;
//       }
      //System.out.println (aw +"\n" + bw);

      String r = "";
      if (a>b)
      r = "YES";
      else if (a == b)
      {
         if ( aw >= bw ) r = "YES";
         else r = "NO";
      }
      else
      {
         if ( aw > bw ) r = "YES";
         else if ( aw == bw ) r = "YES";
         else r = "NO";
      }

       System.out.println (r);
//       else System.out.println ("NO");
   }
}


import java.util.*;
public class FishWeights
{
   public static void main (String []args)
   {
      Scanner sc = new Scanner (System.in);
      int a = sc.nextInt(), b = sc.nextInt(), i, k = sc.nextInt();
      long aw = 0, bw = 0;
      int max = 0; boolean flag = true;
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for ( i = 0; i < a; i ++)
      {
         int temp = sc.nextInt(); if (temp>max) max = temp;
         if (!map.containsKey(temp)) map.put(temp, 1);
         else map.put(temp, (map.get(temp)+1));

      }

      for ( i = 0; i < b; i ++)
      {
         int temp = sc.nextInt();
         if (temp>=max){
            max = temp;
              flag = false;
          }

         if (!map.containsKey(temp)) map.put(temp, -1);
         else map.put(temp, (map.get(temp)-1));
      }

      int an = a, bn = b;
      a = 0; b = 0;
      max = 0;

      for (Integer key : map.keySet()) {
         if ( map.get(key) > 0)
         {   aw+= (key*map.get(key));
            a++;
            if ( key > max)
            {
               flag = true;
               max = key;
            }
         }
         else if (map.get(key) < 0)
         {   bw-= (key*map.get(key));
            b++;
            if ( key > max)
            {
               max = key;
               flag = false;
             }
         }
      }
      if ( flag)
      {
         System.out.println ("YES");
         return;
      }
      //System.out.println (aw +"\n" + bw);

      // if (aw>bw&&a>b) System.out.println ("YES");
//       else if ( aw>bw&&a<b) System.out.println ("YES");
//       else if ( aw<bw&&a>b) System.out.println ("YES");
//       else if ( aw<bw&&a<b)System.out.println ("NO");
//       else if ( a == b)
//       {
//          if (aw >= bw) System.out.println ("YES");
//          else System.out.println("NO");
//       }
//       else if (aw == bw)
//       {
//          if (a>=b) System.out.println ("YES");
//          else System.out.println ("NO");
//       }

      if (aw>bw || a>b) System.out.println ("YES");
      else System.out.println("NO");

       // System.out.println ("YES");
//       else System.out.println ("NO");
   }
}


import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	public void solve() throws Exception {
		int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
		int[] w = new int[n + m];
		int[] w1 = new int[n];
		for (int i = 0; i < n; i++) {
			w1[i] = sc.nextInt();
			w[i] = w1[i];
		}
		int[] w2 = new int[m];
		for (int i = 0; i < m; i++) {
			w2[i] = sc.nextInt();
			w[n + i] = w2[i];
		}
		Arrays.sort(w);
		int[] ww = new int[n + m];
		int cnt = 0;
		for (int i = 0; i < n + m; i++) {
			if (i == 0 || w[i] != w[i - 1]) {
				ww[cnt++] = w[i];
			}
		}
		int[] wbal = new int[cnt];
		for (int i = 0; i < n; i++) {
			int pos = Arrays.binarySearch(ww, 0, cnt, w1[i]);
			wbal[pos]++;
		}
		for (int i = 0; i < m; i++) {
			int pos = Arrays.binarySearch(ww, 0, cnt, w2[i]);
			wbal[pos]--;
		}
		int curbal = 0;
		for (int i = cnt - 1; i >= 0; i--) {
			curbal += wbal[i];
			if (curbal > 0) {
				out.println("YES");
				return;
			}
		}
		out.println("NO");
	}

	static Throwable uncaught;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable uncaught) {
			Solution.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		if (Solution.uncaught != null) {
			throw Solution.uncaught;
		}
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

	public String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

}


import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	int[] prefixFunction(String str) {
		int[] pi = new int[str.length()];
		for (int i = 1; i < str.length(); i++) {
			int k = pi[i - 1];
			while (k > 0 && str.charAt(i) != str.charAt(k)) {
				k = pi[k - 1];
			}
			if (str.charAt(i) == str.charAt(k)) {
				k++;
			}
			pi[i] = k;
		}
		return pi;
	}

	int[] getCnt(String str) {
		int[] cnt = new int[str.length()];
		for (int i = 0; i < str.length(); i++) {
			if (i > 0) {
				cnt[i] = cnt[i - 1];
			}
			if (str.charAt(i) == '1') {
				cnt[i]++;
			}
		}
		return cnt;
	}

	int sum(int[] sarr, int l, int r) {
		int ans = sarr[r];
		if (l > 0) {
			ans -= sarr[l - 1];
		}
		return ans;
	}

	public void solve() throws Exception {
		String a = in.readLine();
		String b = in.readLine();
		String str = b + "#" + a;
		int[] cnta = getCnt(a), cntb = getCnt(b);
		int[] pi = prefixFunction(str);
		int pii = pi[b.length() + 1 + a.length() - 1];
		do {
			int pos = a.length() - pii - 1;
			int times = pos >= 0 ? cnta[pos] : 0;
			if (cnta[a.length() - 1] % 2 == 1) {
				if (pii < b.length()) {
					if (pos == a.length() - 1 || b.charAt(pii) == '1') {
						times++;
					} else {
						times--;
					}
				}
			}
			if (times >= sum(cntb, pii, b.length() - 1)) {
				out.println("YES");
				return;
			}
			if (pii > 0) {
				pii = pi[pii - 1];
			}
		} while (pii > 0);
		out.println("NO");
	}

	static Throwable uncaught;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable uncaught) {
			Solution.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		if (Solution.uncaught != null) {
			throw Solution.uncaught;
		}
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

	public String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

}


import java.io.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class B implements Runnable {

    // leave empty to read from stdin/stdout
    private static final String TASK_NAME_FOR_IO = "";

    // file names
    private static final String FILE_IN = TASK_NAME_FOR_IO + ".in";
    private static final String FILE_OUT = TASK_NAME_FOR_IO + ".out";

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tokenizer = new StringTokenizer("");

    public static void main(String[] args) {
        new Thread(new B()).start();
    }

    Map<Integer, Integer> cnt = new TreeMap<Integer, Integer>();
    ArrayList<Integer> data = new ArrayList<Integer>();

    private void add(int idx, int d) {
        if (cnt.containsKey(idx)) {
            cnt.put(idx, cnt.get(idx) + d);
        } else {
            cnt.put(idx, d);
        }
    }

    private void solve() throws IOException {
        int p1 = nextInt();
        int p2 = nextInt();
        int k = nextInt();

        for (int i = 0; i < p1; i++) {
            int idx = nextInt();
            add(idx, 1);
        }

        for (int i = 0; i < p2; i++) {
            int idx = nextInt();
            add(idx, -1);
        }

        for (Map.Entry<Integer, Integer> e : cnt.entrySet()) {
            int p = e.getValue();
            if (p != 0) {
                data.add(p);
            }
        }

        boolean result;
        if (data.isEmpty()) {
            result = false;
        } else {

            result = false;
            int sumTail = 0;
            for (int idx = data.size() - 1; idx >= 0; idx--) {
                sumTail += data.get(idx);
                if (sumTail > 0) {
                    result = true;
                    break;
                }
            }

            /*
            int last = data.get(data.size() - 1);
            if (last > 0) {
                result = true;
            } else {

                // count all negative at the end
                int sumTail = 0;
                int idx = data.size() - 1;
                while (idx >= 0 && data.get(idx) < 0) {
                    sumTail += Math.abs(data.get(idx));
                    idx--;
                }

                // no positive?
                if (idx < 0) {
                    result = false;
                } else {
                    // count all positive
                    int sumHead = 0;
                    int idx2 = idx;
                    while (idx2 >= 0 && data.get(idx2) > 0) {
                        sumHead += data.get(idx2);
                        idx2--;
                    }

                    result = sumHead > sumTail;
                }

            }
            */

        }

        if (result) {
            out.print("YES");
        } else {
            out.print("NO");
        }
    }

    public void run() {
        long timeStart = System.currentTimeMillis();

        boolean fileIO = TASK_NAME_FOR_IO.length() > 0;
        try {

            if (fileIO) {
                in = new BufferedReader(new FileReader(FILE_IN));
                out = new PrintWriter(new FileWriter(FILE_OUT));
            } else {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            solve();

            in.close();
            out.close();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        long timeEnd = System.currentTimeMillis();

        if (fileIO) {
            System.out.println("Time spent: " + (timeEnd - timeStart) + " ms");
        }
    }

    private String nextToken() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private BigInteger nextBigInt() throws IOException {
        return new BigInteger(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

}


import java.io.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class B implements Runnable {

    // leave empty to read from stdin/stdout
    private static final String TASK_NAME_FOR_IO = "";

    // file names
    private static final String FILE_IN = TASK_NAME_FOR_IO + ".in";
    private static final String FILE_OUT = TASK_NAME_FOR_IO + ".out";

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tokenizer = new StringTokenizer("");

    public static void main(String[] args) {
        new Thread(new B()).start();
    }

    Map<Integer, Integer> cnt = new TreeMap<Integer, Integer>();
    ArrayList<Integer> data = new ArrayList<Integer>();

    private void add(int idx, int d) {
        if (cnt.containsKey(idx)) {
            cnt.put(idx, cnt.get(idx) + d);
        } else {
            cnt.put(idx, d);
        }
    }

    private void solve() throws IOException {
        int p1 = nextInt();
        int p2 = nextInt();
        int k = nextInt();

        for (int i = 0; i < p1; i++) {
            int idx = nextInt();
            add(idx, 1);
        }

        for (int i = 0; i < p2; i++) {
            int idx = nextInt();
            add(idx, -1);
        }

        for (Map.Entry<Integer, Integer> e : cnt.entrySet()) {
            int p = e.getValue();
            if (p != 0) {
                data.add(p);
            }
        }

        boolean result;
        if (data.isEmpty()) {
            result = false;
        } else {
            int last = data.get(data.size() - 1);
            if (last > 0) {
                result = true;
            } else {

                // count all negative at the end
                int sumTail = 0;
                int idx = data.size() - 1;
                while (idx >= 0 && data.get(idx) < 0) {
                    sumTail += Math.abs(data.get(idx));
                    idx--;
                }

                // no positive?
                if (idx < 0) {
                    result = false;
                } else {
                    // count all positive
                    int sumHead = 0;
                    int idx2 = idx;
                    while (idx2 >= 0 && data.get(idx2) > 0) {
                        sumHead += data.get(idx2);
                        idx2--;
                    }

                    result = sumHead > sumTail;
                }

            }
        }

        if (result) {
            out.print("YES");
        } else {
            out.print("NO");
        }
    }

    public void run() {
        long timeStart = System.currentTimeMillis();

        boolean fileIO = TASK_NAME_FOR_IO.length() > 0;
        try {

            if (fileIO) {
                in = new BufferedReader(new FileReader(FILE_IN));
                out = new PrintWriter(new FileWriter(FILE_OUT));
            } else {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            solve();

            in.close();
            out.close();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        long timeEnd = System.currentTimeMillis();

        if (fileIO) {
            System.out.println("Time spent: " + (timeEnd - timeStart) + " ms");
        }
    }

    private String nextToken() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private BigInteger nextBigInt() throws IOException {
        return new BigInteger(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

}


import java.io.*;
import java.util.*;
import java.math.*;

public class B implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	void solve() throws IOException {
		int n = nextInt(), m = nextInt(), k = nextInt();
		Map<Integer, Integer> countFirst = readMap(n), countSecond = readMap(m);

		out.println(isSubset(countFirst, countSecond) ? "NO" : "YES");
	}

	private boolean isSubset(Map<Integer, Integer> a, Map<Integer, Integer> b) {
		for (int key : a.keySet()) {
			int firstValue = a.get(key);
			Integer secondValueObj = b.get(key);
			int secondValue = (secondValueObj != null) ? secondValueObj : 0;
			//out.println(key + " " + firstValue + " " + secondValue);
			if (firstValue > secondValue)
				return false;
		}
		return true;
	}

	private Map<Integer, Integer> readMap(int n) throws IOException {
		Map<Integer, Integer> count = new TreeMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			int key = nextInt();
			Integer before = count.get(key);
			count.put(key, (before == null ? 0 : before) + 1);
		}
		return count;
	}

	public static void main(String[] args) {
		new B().run();
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
				// in = new BufferedReader(new FileReader("input.txt"));
				// out = new PrintWriter(new FileWriter("output.txt"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class B implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	void solve() throws IOException {
		int n = nextInt(), m = nextInt(), k = nextInt();
		Map<Integer, Integer> countFirst = readMap(n), countSecond = readMap(m);

		out.println(!isOk(countFirst, countSecond) ? "NO" : "YES");
	}

	private boolean isOk(Map<Integer, Integer> a, Map<Integer, Integer> b) {
		Set<Integer> allValues = new TreeSet(a.keySet());
		allValues.addAll(b.keySet());
		List<Integer> allValuesReversed = new ArrayList<Integer>(allValues);
		Collections.reverse(allValuesReversed);

		int curBalance = 0;

		for (int key : allValuesReversed) {
			int firstCount = getSmart(a, key);
			int secondCount = getSmart(b, key);

			curBalance += (firstCount - secondCount);

			if(curBalance > 0)
				return true;

		}

		return false;
	}

	private int getSmart(Map<Integer, Integer> a, int key) {
		Integer res = a.get(key);
		return (res == null) ? 0 : res;
	}

	private Map<Integer, Integer> readMap(int n) throws IOException {
		Map<Integer, Integer> count = new TreeMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			int key = nextInt();
			Integer before = count.get(key);
			count.put(key, (before == null ? 0 : before) + 1);
		}
		return count;
	}

	public static void main(String[] args) {
		new B().run();
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
				// in = new BufferedReader(new FileReader("input.txt"));
				// out = new PrintWriter(new FileWriter("output.txt"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();// who cares
                                                                    // about k
                                                                    // anyway
        int[] first = new int[n];
        int[] second = new int[m];
        for (int i = 0; i < n; i++)
            first[i] = in.nextInt();
        for (int i = 0; i < m; i++)
            second[i] = in.nextInt();
        Integer[] total = new Integer[n + m];
        for (int i = 0; i < n; i++)
            total[i] = first[i];
        for (int i = 0; i < m; i++)
            total[i + n] = second[i];
        Arrays.sort(total);
        int[] index = new int[n + m];
        index[0] = 0;
        for (int i = 1; i < total.length; i++) {
            if (total[i] == total[i - 1])
                index[i] = index[i - 1];
            else
                index[i] = index[i - 1] + 1;
        }
        int max = index[index.length - 1];
        int[] freq = new int[max + 1];
        for (int i = 0; i < first.length; i++) {
            int lo = 0;
            int hi = index.length - 1;
            while (hi > lo) {
                int mid = (lo + hi) / 2;
                if (total[mid] >= first[i])
                    hi = mid;
                else
                    lo = mid + 1;
            }
            freq[index[lo]]++;
        }
        for (int i = 0; i < second.length; i++) {
            int lo = 0;
            int hi = index.length - 1;
            while (hi > lo) {
                int mid = (lo + hi) / 2;
                if (total[mid] >= second[i])
                    hi = mid;
                else
                    lo = mid + 1;
            }
            freq[index[lo]]--;
        }
        int sum = 0;
        for (int i = freq.length - 1; i >= 0; i--) {
            sum += freq[i];
            if (sum > 0) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }

}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Artem_Mikhalevitch
 */
public class Main extends ASolver {

    int n;
    int m;
    int k;
    long[] diff;

    //Pattern p;
    //Matcher m;
    public static void main(String[] args) throws ParseException {

        Main s = new Main();
        s.init();
        if (s.readData()) {
            //s.solve();
            s.writeData("" + s.solve());
        }

    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public boolean readData() {
        try {
            n = nextInt();
            m = nextInt();
            k = nextInt();
            diff = new long[k+1];
            for (int i = 0; i < n; i++) {
                diff[nextInt()]++;
            }
            for (int i = 0; i < m; i++) {
                diff[nextInt()]--;
            }
        } catch (Exception ex) {
            System.out.println(ex.getCause());
            System.out.println(ex.getMessage());
            return false;
        }
        return true;
    }

    public double[] sort(double[] mas1, double[] mas2) {
        int l1 = mas1.length;
        int l2 = mas2.length;
        double[] result = new double[l1 + l2];
        int i1 = 0, i2 = 0;
        int i = 0;
        for (i = 0; i1 < l1 && i2 < l2; i++) {
            if (mas1[i1] <= mas2[i2]) {
                result[i] = mas1[i1++];
            } else {
                result[i] = mas2[i2++];
            }
        }
        for (int j = i; i1 < l1; j++) {
            result[j] = mas1[i1++];
        }
        for (int j = i; i2 < l2; j++) {
            result[j] = mas2[i2++];
        }
        return result;
    }

    public String solve() {
        String result = "NO";
        long minuses = 0;
        for (int i = k ; i >= 0; i--) {
            if (diff[i] > 0) {
                if (minuses <= 0)  return "YES";
                 else minuses -= diff[i];
            }
            else if(diff[i] < 0) minuses-=diff[i];
        }
        return result;
    }
}

abstract class ASolver {

    protected StringTokenizer tokens;
    protected BufferedReader input;
    protected PrintWriter output;

    public void init() {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public abstract boolean readData();

    public void writeData(String result) {
        System.out.println(result);
    }

    public void writeData(int result) {
        System.out.println(result);
    }

    public void writeData(long result) {
        System.out.println(result);
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    public String nextLine() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine(), "\n");
        }
        return tokens.nextToken();
    }

    public long infinityImitator(long a, long b) {
        if (a == Long.MIN_VALUE) {
            return Long.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    public int infinityImitator(int a, int b) {
        if (a == Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    /*
     * public long max(long... a) { long result = Long.MIN_VALUE; for (int i =
     * 0; i < a.length; i++) { result = Math.max(result, a[i]); } return result;
     * }
     */
    public int indexMax(int... a) {
        int result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int indexMax(long... a) {
        long result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int max(int... a) {
        int result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }

    public long max(long... a) {
        long result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Artem_Mikhalevitch
 */
public class Main extends ASolver {

    int n;
    int m;
    int k;
    long[] diff;
    ArrayList<Long> a;
    ArrayList<Long> b;

    //Pattern p;
    //Matcher m;
    public static void main(String[] args) throws ParseException {

        Main s = new Main();
        s.init();
        if (s.readData()) {
            //s.solve();
            s.writeData("" + s.solve());
        }
    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public boolean readData() {
        try {
            n = nextInt();
            m = nextInt();
            k = nextInt();
            a = new ArrayList<Long>(k);
            b = new ArrayList<Long>(k);
            /*
             * diff = new long[k+1]; for (int i = 0; i < n; i++) {
             * diff[nextInt()]++; } for (int i = 0; i < m; i++) {
             * diff[nextInt()]--;
            }
             */
            for (int i = 0; i < n; i++) {
                a.add((long) nextInt());
            }
            for (int i = 0; i < m; i++) {
                b.add((long) nextInt());
            }

        } catch (Exception ex) {
            System.out.println(ex.getCause());
            System.out.println(ex.getMessage());
            return false;
        }
        return true;
    }

    public double[] sort(double[] mas1, double[] mas2) {
        int l1 = mas1.length;
        int l2 = mas2.length;
        double[] result = new double[l1 + l2];
        int i1 = 0, i2 = 0;
        int i = 0;
        for (i = 0; i1 < l1 && i2 < l2; i++) {
            if (mas1[i1] <= mas2[i2]) {
                result[i] = mas1[i1++];
            } else {
                result[i] = mas2[i2++];
            }
        }
        for (int j = i; i1 < l1; j++) {
            result[j] = mas1[i1++];
        }
        for (int j = i; i2 < l2; j++) {
            result[j] = mas2[i2++];
        }
        return result;
    }

    public String solve() {
        String result = "NO";
        Collections.sort(a);
        Collections.sort(b);
        if(n>m){
        return "YES";
        }
        int aSize=a.size();
        int bSize=b.size();
        for(int i=aSize-1,j=bSize-1; i>=0; i-- , j--){
            if(a.get(i)>b.get(j)){
                    return "YES";
            }
        }
        /*
         * long minuses = 0; for (int i = k ; i >= 0; i--) { if (diff[i] > 0) {
         * minuses -= diff[i]; if (minuses < 0) return "YES"; } else if(diff[i]
         * < 0) minuses-=diff[i];
        }
         */
        return result;
    }
}

abstract class ASolver {

    protected StringTokenizer tokens;
    protected BufferedReader input;
    protected PrintWriter output;

    public void init() {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public abstract boolean readData();

    public void writeData(String result) {
        System.out.println(result);
    }

    public void writeData(int result) {
        System.out.println(result);
    }

    public void writeData(long result) {
        System.out.println(result);
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    public String nextLine() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine(), "\n");
        }
        return tokens.nextToken();
    }

    public long infinityImitator(long a, long b) {
        if (a == Long.MIN_VALUE) {
            return Long.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    public int infinityImitator(int a, int b) {
        if (a == Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    /*
     * public long max(long... a) { long result = Long.MIN_VALUE; for (int i =
     * 0; i < a.length; i++) { result = Math.max(result, a[i]); } return result;
     * }
     */
    public int indexMax(int... a) {
        int result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int indexMax(long... a) {
        long result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int max(int... a) {
        int result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }

    public long max(long... a) {
        long result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Artem_Mikhalevitch
 */
public class Main extends ASolver {

    int n;
    int m;
    int k;
    long[] diff;
    ArrayList<Long> a;
    ArrayList<Long> b;

    //Pattern p;
    //Matcher m;
    public static void main(String[] args) throws ParseException {

        Main s = new Main();
        s.init();
        if (s.readData()) {
            //s.solve();
            s.writeData("" + s.solve());
        }
    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public boolean readData() {
        try {
            n = nextInt();
            m = nextInt();
            k = nextInt();
            a = new ArrayList<Long>(n);
            b = new ArrayList<Long>(m);
            /*
             * diff = new long[k+1]; for (int i = 0; i < n; i++) {
             * diff[nextInt()]++; } for (int i = 0; i < m; i++) {
             * diff[nextInt()]--;
            }
             */
            for (int i = 0; i < n; i++) {
                a.add((long) nextInt());
            }
            for (int i = 0; i < m; i++) {
                b.add((long) nextInt());
            }

        } catch (Exception ex) {
            System.out.println(ex.getCause());
            System.out.println(ex.getMessage());
            return false;
        }
        return true;
    }

    public double[] sort(double[] mas1, double[] mas2) {
        int l1 = mas1.length;
        int l2 = mas2.length;
        double[] result = new double[l1 + l2];
        int i1 = 0, i2 = 0;
        int i = 0;
        for (i = 0; i1 < l1 && i2 < l2; i++) {
            if (mas1[i1] <= mas2[i2]) {
                result[i] = mas1[i1++];
            } else {
                result[i] = mas2[i2++];
            }
        }
        for (int j = i; i1 < l1; j++) {
            result[j] = mas1[i1++];
        }
        for (int j = i; i2 < l2; j++) {
            result[j] = mas2[i2++];
        }
        return result;
    }

    public String solve() {
        String result = "NO";
        Collections.sort(a);
        Collections.sort(b);
        if(n>m){
        return "YES";
        }
        int aSize=a.size();
        int bSize=b.size();
        for(int i=aSize-1,j=bSize-1; i>=0; i-- , j--){
            if(a.get(i)>b.get(j)){
                    return "YES";
            }
        }
        /*
         * long minuses = 0; for (int i = k ; i >= 0; i--) { if (diff[i] > 0) {
         * minuses -= diff[i]; if (minuses < 0) return "YES"; } else if(diff[i]
         * < 0) minuses-=diff[i];
        }
         */
        return result;
    }
}

abstract class ASolver {

    protected StringTokenizer tokens;
    protected BufferedReader input;
    protected PrintWriter output;

    public void init() {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public abstract boolean readData();

    public void writeData(String result) {
        System.out.println(result);
    }

    public void writeData(int result) {
        System.out.println(result);
    }

    public void writeData(long result) {
        System.out.println(result);
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    public String nextLine() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine(), "\n");
        }
        return tokens.nextToken();
    }

    public long infinityImitator(long a, long b) {
        if (a == Long.MIN_VALUE) {
            return Long.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    public int infinityImitator(int a, int b) {
        if (a == Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    /*
     * public long max(long... a) { long result = Long.MIN_VALUE; for (int i =
     * 0; i < a.length; i++) { result = Math.max(result, a[i]); } return result;
     * }
     */
    public int indexMax(int... a) {
        int result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int indexMax(long... a) {
        long result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int max(int... a) {
        int result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }

    public long max(long... a) {
        long result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Artem_Mikhalevitch
 */
public class Main extends ASolver {

    int n;
    int m;
    int k;
    long[] diff;

    //Pattern p;
    //Matcher m;
    public static void main(String[] args) throws ParseException {

        Main s = new Main();
        s.init();
        if (s.readData()) {
            //s.solve();
            s.writeData("" + s.solve());
        }

    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public boolean readData() {
        try {
            n = nextInt();
            m = nextInt();
            k = nextInt();
            diff = new long[k+1];
            for (int i = 0; i < n; i++) {
                diff[nextInt()]++;
            }
            for (int i = 0; i < m; i++) {
                diff[nextInt()]--;
            }
        } catch (Exception ex) {
            System.out.println(ex.getCause());
            System.out.println(ex.getMessage());
            return false;
        }
        return true;
    }

    public double[] sort(double[] mas1, double[] mas2) {
        int l1 = mas1.length;
        int l2 = mas2.length;
        double[] result = new double[l1 + l2];
        int i1 = 0, i2 = 0;
        int i = 0;
        for (i = 0; i1 < l1 && i2 < l2; i++) {
            if (mas1[i1] <= mas2[i2]) {
                result[i] = mas1[i1++];
            } else {
                result[i] = mas2[i2++];
            }
        }
        for (int j = i; i1 < l1; j++) {
            result[j] = mas1[i1++];
        }
        for (int j = i; i2 < l2; j++) {
            result[j] = mas2[i2++];
        }
        return result;
    }

    public String solve() {
        String result = "NO";
        long minuses = 0;
        for (int i = k ; i >= 0; i--) {
            if (diff[i] > 0) {
                if (minuses <= 0)  return "YES";
                 else minuses -= diff[i];
            }
            else if(diff[i] < 0) minuses+=diff[i];
        }
        return result;
    }
}

abstract class ASolver {

    protected StringTokenizer tokens;
    protected BufferedReader input;
    protected PrintWriter output;

    public void init() {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public abstract boolean readData();

    public void writeData(String result) {
        System.out.println(result);
    }

    public void writeData(int result) {
        System.out.println(result);
    }

    public void writeData(long result) {
        System.out.println(result);
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    public String nextLine() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine(), "\n");
        }
        return tokens.nextToken();
    }

    public long infinityImitator(long a, long b) {
        if (a == Long.MIN_VALUE) {
            return Long.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    public int infinityImitator(int a, int b) {
        if (a == Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    /*
     * public long max(long... a) { long result = Long.MIN_VALUE; for (int i =
     * 0; i < a.length; i++) { result = Math.max(result, a[i]); } return result;
     * }
     */
    public int indexMax(int... a) {
        int result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int indexMax(long... a) {
        long result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int max(int... a) {
        int result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }

    public long max(long... a) {
        long result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Artem_Mikhalevitch
 */
public class Main extends ASolver {

    int n;
    int m;
    int k;
    long[] diff;

    //Pattern p;
    //Matcher m;
    public static void main(String[] args) throws ParseException {

        Main s = new Main();
        s.init();
        if (s.readData()) {
            //s.solve();
            s.writeData("" + s.solve());
        }

    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public boolean readData() {
        try {
            n = nextInt();
            m = nextInt();
            k = nextInt();
            diff = new long[k+1];
            for (int i = 0; i < n; i++) {
                diff[nextInt()]++;
            }
            for (int i = 0; i < m; i++) {
                diff[nextInt()]--;
            }
        } catch (Exception ex) {
            System.out.println(ex.getCause());
            System.out.println(ex.getMessage());
            return false;
        }
        return true;
    }

    public double[] sort(double[] mas1, double[] mas2) {
        int l1 = mas1.length;
        int l2 = mas2.length;
        double[] result = new double[l1 + l2];
        int i1 = 0, i2 = 0;
        int i = 0;
        for (i = 0; i1 < l1 && i2 < l2; i++) {
            if (mas1[i1] <= mas2[i2]) {
                result[i] = mas1[i1++];
            } else {
                result[i] = mas2[i2++];
            }
        }
        for (int j = i; i1 < l1; j++) {
            result[j] = mas1[i1++];
        }
        for (int j = i; i2 < l2; j++) {
            result[j] = mas2[i2++];
        }
        return result;
    }

    public String solve() {
        String result = "NO";
        long minuses = 0;
        for (int i = k ; i >= 0; i--) {
            if (diff[i] > 0) {
                minuses -= diff[i];
                if (minuses < 0)  return "YES";
            }
            else if(diff[i] < 0) minuses-=diff[i];
        }
        return result;
    }
}

abstract class ASolver {

    protected StringTokenizer tokens;
    protected BufferedReader input;
    protected PrintWriter output;

    public void init() {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public abstract boolean readData();

    public void writeData(String result) {
        System.out.println(result);
    }

    public void writeData(int result) {
        System.out.println(result);
    }

    public void writeData(long result) {
        System.out.println(result);
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    public String nextLine() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine(), "\n");
        }
        return tokens.nextToken();
    }

    public long infinityImitator(long a, long b) {
        if (a == Long.MIN_VALUE) {
            return Long.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    public int infinityImitator(int a, int b) {
        if (a == Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    /*
     * public long max(long... a) { long result = Long.MIN_VALUE; for (int i =
     * 0; i < a.length; i++) { result = Math.max(result, a[i]); } return result;
     * }
     */
    public int indexMax(int... a) {
        int result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int indexMax(long... a) {
        long result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int max(int... a) {
        int result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }

    public long max(long... a) {
        long result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Artem_Mikhalevitch
 */
public class Main extends ASolver {

    int n;
    int m;
    int k;
    long[] diff;

    //Pattern p;
    //Matcher m;
    public static void main(String[] args) throws ParseException {

        Main s = new Main();
        s.init();
        if (s.readData()) {
            //s.solve();
            s.writeData("" + s.solve());
        }

    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public boolean readData() {
        try {
            n = nextInt();
            m = nextInt();
            k = nextInt();
            diff = new long[k+1];
            for (int i = 0; i < n; i++) {
                diff[nextInt()]++;
            }
            for (int i = 0; i < m; i++) {
                diff[nextInt()]--;
            }
        } catch (Exception ex) {
            System.out.println(ex.getCause());
            System.out.println(ex.getMessage());
            return false;
        }
        return true;
    }

    public double[] sort(double[] mas1, double[] mas2) {
        int l1 = mas1.length;
        int l2 = mas2.length;
        double[] result = new double[l1 + l2];
        int i1 = 0, i2 = 0;
        int i = 0;
        for (i = 0; i1 < l1 && i2 < l2; i++) {
            if (mas1[i1] <= mas2[i2]) {
                result[i] = mas1[i1++];
            } else {
                result[i] = mas2[i2++];
            }
        }
        for (int j = i; i1 < l1; j++) {
            result[j] = mas1[i1++];
        }
        for (int j = i; i2 < l2; j++) {
            result[j] = mas2[i2++];
        }
        return result;
    }

    public String solve() {
        String result = "NO";
        long minuses = 0;
        for (int i = k ; i >= 0; i--) {
            if (diff[i] > 0) {
                minuses -= diff[i];
                if (minuses <= 0)  return "YES";
            }
            else if(diff[i] < 0) minuses-=diff[i];
        }
        return result;
    }
}

abstract class ASolver {

    protected StringTokenizer tokens;
    protected BufferedReader input;
    protected PrintWriter output;

    public void init() {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public abstract boolean readData();

    public void writeData(String result) {
        System.out.println(result);
    }

    public void writeData(int result) {
        System.out.println(result);
    }

    public void writeData(long result) {
        System.out.println(result);
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    public String nextLine() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine(), "\n");
        }
        return tokens.nextToken();
    }

    public long infinityImitator(long a, long b) {
        if (a == Long.MIN_VALUE) {
            return Long.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    public int infinityImitator(int a, int b) {
        if (a == Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    /*
     * public long max(long... a) { long result = Long.MIN_VALUE; for (int i =
     * 0; i < a.length; i++) { result = Math.max(result, a[i]); } return result;
     * }
     */
    public int indexMax(int... a) {
        int result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int indexMax(long... a) {
        long result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int max(int... a) {
        int result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }

    public long max(long... a) {
        long result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class B implements Runnable {

    Scanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Thread(null, new B(), "", 64*1024*1024).start();
        //new Template().run();
    }

    public void run() {
        try {
            long t1 = 0, t2 = 0;
            if (LOCAL) {
                t1 = System.currentTimeMillis();
            }
            Locale.setDefault(Locale.US);
            if (LOCAL) {
                in = new Scanner("input.txt");
                out = new PrintWriter("output.txt");
            } else {
                in = new Scanner(System.in);
                out = new PrintWriter(System.out);
            }
            solve();
            in.close();
            out.close();
            if (LOCAL) {
                t2 = System.currentTimeMillis();
                System.err.println("Time = " + (t2 - t1) + " ms.");
            }
        } catch (Throwable e) {
            e.printStackTrace(System.err);
            throw new RuntimeException();
        }
    }

    int readInt() throws IOException {
        return in.nextInt();
    }

    long readLong() throws IOException {
        return in.nextLong();
    }

    double readDouble() throws IOException {
        return in.nextDouble();
    }

    static class Mergesort {

        private Mergesort() {}

        public static void sort(int[] a) {
            mergesort(a, 0, a.length - 1);
        }

        public static void sort(long[] a) {
            mergesort(a, 0, a.length - 1);
        }

        public static void sort(double[] a) {
            mergesort(a, 0, a.length - 1);
        }

        private static final int MAGIC_VALUE = 42;

        private static void mergesort(int[] a, int leftIndex, int rightIndex) {
            if (leftIndex < rightIndex) {
                if (rightIndex - leftIndex <= MAGIC_VALUE) {
                    insertionSort(a, leftIndex, rightIndex);
                } else {
                    int middleIndex = (leftIndex + rightIndex) / 2;
                    mergesort(a, leftIndex, middleIndex);
                    mergesort(a, middleIndex + 1, rightIndex);
                    merge(a, leftIndex, middleIndex, rightIndex);
                }
            }
        }

        private static void mergesort(long[] a, int leftIndex, int rightIndex) {
            if (leftIndex < rightIndex) {
                if (rightIndex - leftIndex <= MAGIC_VALUE) {
                    insertionSort(a, leftIndex, rightIndex);
                } else {
                    int middleIndex = (leftIndex + rightIndex) / 2;
                    mergesort(a, leftIndex, middleIndex);
                    mergesort(a, middleIndex + 1, rightIndex);
                    merge(a, leftIndex, middleIndex, rightIndex);
                }
            }
        }

        private static void mergesort(double[] a, int leftIndex, int rightIndex) {
            if (leftIndex < rightIndex) {
                if (rightIndex - leftIndex <= MAGIC_VALUE) {
                    insertionSort(a, leftIndex, rightIndex);
                } else {
                    int middleIndex = (leftIndex + rightIndex) / 2;
                    mergesort(a, leftIndex, middleIndex);
                    mergesort(a, middleIndex + 1, rightIndex);
                    merge(a, leftIndex, middleIndex, rightIndex);
                }
            }
        }

        private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
            int length1 = middleIndex - leftIndex + 1;
            int length2 = rightIndex - middleIndex;
            int[] leftArray = new int[length1];
            int[] rightArray = new int[length2];
            System.arraycopy(a, leftIndex, leftArray, 0, length1);
            System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
            for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                if (i == length1) {
                    a[k] = rightArray[j++];
                } else if (j == length2) {
                    a[k] = leftArray[i++];
                } else {
                    a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                }
            }
        }

        private static void merge(long[] a, int leftIndex, int middleIndex, int rightIndex) {
            int length1 = middleIndex - leftIndex + 1;
            int length2 = rightIndex - middleIndex;
            long[] leftArray = new long[length1];
            long[] rightArray = new long[length2];
            System.arraycopy(a, leftIndex, leftArray, 0, length1);
            System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
            for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                if (i == length1) {
                    a[k] = rightArray[j++];
                } else if (j == length2) {
                    a[k] = leftArray[i++];
                } else {
                    a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                }
            }
        }

        private static void merge(double[] a, int leftIndex, int middleIndex, int rightIndex) {
            int length1 = middleIndex - leftIndex + 1;
            int length2 = rightIndex - middleIndex;
            double[] leftArray = new double[length1];
            double[] rightArray = new double[length2];
            System.arraycopy(a, leftIndex, leftArray, 0, length1);
            System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
            for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                if (i == length1) {
                    a[k] = rightArray[j++];
                } else if (j == length2) {
                    a[k] = leftArray[i++];
                } else {
                    a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                }
            }
        }

        private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
            for (int i = leftIndex + 1; i <= rightIndex; i++) {
                int current = a[i];
                int j = i - 1;
                while (j >= leftIndex && a[j] > current) {
                    a[j + 1] = a[j];
                    j--;
                }
                a[j + 1] = current;
            }
        }

        private static void insertionSort(long[] a, int leftIndex, int rightIndex) {
            for (int i = leftIndex + 1; i <= rightIndex; i++) {
                long current = a[i];
                int j = i - 1;
                while (j >= leftIndex && a[j] > current) {
                    a[j + 1] = a[j];
                    j--;
                }
                a[j + 1] = current;
            }
        }

        private static void insertionSort(double[] a, int leftIndex, int rightIndex) {
            for (int i = leftIndex + 1; i <= rightIndex; i++) {
                double current = a[i];
                int j = i - 1;
                while (j >= leftIndex && a[j] > current) {
                    a[j + 1] = a[j];
                    j--;
                }
                a[j + 1] = current;
            }
        }

    }

    void debug(Object... o) {
        if (LOCAL) {
            System.err.println(Arrays.deepToString(o));
        }
    }

    final static boolean LOCAL = System.getProperty("ONLINE_JUDGE") == null;//System.getProperty("os.name") != null && System.getProperty("os.name").contains("Windows");//

//------------------------------------------------------------------------------

    void solve() throws IOException {
        int n = readInt();
        int m = readInt();
        int k = readInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for (int i = 0; i < n; i++) {
            a[i] = readInt();
        }
        for (int i = 0; i < m; i++) {
            b[i] = readInt();
        }
        if (n > m) {
            out.println("YES");
            return;
        }
        Mergesort.sort(a);
        Mergesort.sort(b);
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        for (int i = 0, j = 0; i < n || j < m; ) {
            if (j == m) {
                add(map, a[i++]);
            } else if (i == n) {
                add(map, b[j++]);
            } else if (a[i] < b[j]) {
                add(map, a[i++]);
            } else {
                add(map, b[j++]);
            }
        }
        for (int i = 0; i < n; i++) {
            a[i] = map.get(a[i]);
        }
        for (int i = 0; i < m; i++) {
            b[i] = map.get(b[i]);
        }
        int[] acnts = new int[map.size()];
        int[] bcnts = new int[map.size()];
        for (int x : a) {
            acnts[x]++;
        }
        for (int x : b) {
            bcnts[x]++;
        }
        debug(acnts);
        debug(bcnts);
        for (int i = 1; i < acnts.length; i++) {
            acnts[i] += acnts[i-1];
        }
        for (int i = 1; i < bcnts.length; i++) {
            bcnts[i] += bcnts[i-1];
        }
        debug(acnts);
        debug(bcnts);
        for (int begin = 0; begin <= acnts.length - 1; begin++) {
            int asum = getSum(acnts, begin, acnts.length - 1);
            int bsum = getSum(bcnts, begin, bcnts.length - 1);
            debug(asum, bsum);
            if (asum > bsum) {
                out.println("YES");
                return;
            }
        }
        out.println("NO");
    }

    private void add(TreeMap<Integer, Integer> map, int x) {
        if (!map.containsKey(x)) {
            map.put(x, map.size());
        }
    }

    private int getSum(int[] a, int L, int R) {
        int s = a[R];
        if (L > 0) s -= a[L-1];
        return s;
    }

}


import java.util.Arrays;
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt(); int b = s.nextInt(); int k = s.nextInt();
		int[] al = new int[a]; int[] bo = new int[b];
		for(int i = 0; i < a; i++)
			al[i] = s.nextInt();
		for(int i = 0; i < b; i++)
			bo[i] = s.nextInt();
		if(a > b)
			System.out.println("YES");
		else {
			Arrays.sort(al); Arrays.sort(bo);
			boolean f = false; int i = 0; int j = 0;
			for(i = 0; i < b; i++) {
				if(bo[i] < al[j]) {
					f = true; break;
				}
			while(j < a && bo[i] > al[j])
				j++;
			}

			if(f) System.out.println("YES");
			else System.out.println("NO");

		}
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt(); int b = s.nextInt(); int k = s.nextInt();
		int[] al = new int[a]; int[] bo = new int[b];
		for(int i = 0; i < a; i++)
			al[i] = s.nextInt();
		for(int i = 0; i < b; i++)
			bo[i] = s.nextInt();
		if(a > b)
			System.out.println("YES");
		else {
			Arrays.sort(al); Arrays.sort(bo);
			boolean f = false; int i = b-1; int j = a-1;
			while(true) {
				while(i >= 0 && bo[i] > al[j])
					i--;
				if(al[j] == bo[i])
					j--;
				else if(al[j] > bo[i]) {
					f = true; break;
				}
				if(j < 0) break;
			}
			if(f) System.out.println("YES");
			else System.out.println("NO");

		}
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt(); int b = s.nextInt(); int k = s.nextInt();
		int[] al = new int[a]; int[] bo = new int[b];
		for(int i = 0; i < a; i++)
			al[i] = s.nextInt();
		for(int i = 0; i < b; i++)
			bo[i] = s.nextInt();
		if(a > b)
			System.out.println("YES");
		else {
			Arrays.sort(al); Arrays.sort(bo);
			boolean f = false; int i = 0; int j = 0;
			for(i = 0;j < a && i < b; i++) {
				if(bo[i] < al[j]) {
					f = true; break;
				}
			while(j < a && bo[i] > al[j])
				j++;
			}

			if(f) System.out.println("YES");
			else System.out.println("NO");

		}
	}

}