#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   ostream &operator<<(ostream &os, pair<T1, T2> &p);   template <class T>   ostream &operator<<(ostream &os, vector<T> &v);   template <class T>   ostream &operator<<(ostream &os, set<T> &v);   template <class T1, class T2>   ostream &operator<<(ostream &os, map<T1, T2> &v);   const long long mod = 100000007;   const int N = 15;   int n, k;   bool check(vector<int> &a, int x) {     bool flag = true;     vector<int> v;     for (int i = 0; i < n; i++) {       if (v.size() == k) break;       if ((int)v.size() % 2) {         v.push_back(a[i]);       } else if (a[i] <= x) {         v.push_back(a[i]);       }     }     if (v.size() == k) {       return true;     }     v.clear();     for (int i = 0; i < n; i++) {       if (v.size() == k) break;       if ((int)v.size() % 2 == 0) {         v.push_back(a[i]);       } else if (a[i] <= x) {         v.push_back(a[i]);       }     }     if (v.size() == k) {       return true;     }     return false;   }   void TEST_CASES(int cas) {     scanf( %d %d , &n, &k);     vector<int> a(n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     int low = *min_element(a.begin(), a.end()),         high = *max_element(a.begin(), a.end());     int ans = -1;     while (low <= high) {       int mid = (low + high) / 2;       ;       ;       if (check(a, mid)) {         high = mid - 1;         ans = mid;       } else {         low = mid + 1;       }     }     printf( %d n , ans);   }   int main() {     int t = 1, cas = 0;     while (t--) {       TEST_CASES(++cas);     }     return 0;   }   template <class T1, class T2>   ostream &operator<<(ostream &os, pair<T1, T2> &p) {     os <<  {  << p.first <<  ,   << p.second <<  }  ;     return os;   }   template <class T>   ostream &operator<<(ostream &os, vector<T> &v) {     os <<  [  ;     for (int i = 0; i < v.size(); i++) {       os << v[i] <<    ;     }     os <<   ] ;     return os;   }   template <class T>   ostream &operator<<(ostream &os, set<T> &v) {     os <<  [  ;     for (T i : v) {       os << i <<    ;     }     os <<   ] ;     return os;   }   template <class T1, class T2>   ostream &operator<<(ostream &os, map<T1, T2> &v) {     for (auto i : v) {       os <<  Key :   << i.first <<   , Value :   << i.second << endl;     }     return os;   }   