#include using namespace std; #define ll long long #define mod 1000000007 #define INF 1e18 #define nl "\n" #define pb push_back #define eb emplace_back /*Note: emplace_back is faster than push_back*/ #define ppb pop_back #define mp make_pair #define ff first #define ss second #define PI 3.141592653589793238462 #define set_bits __builtin_popcountll #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() bool sumUp(unordered_map &mp, int k, vector &nums) { int n = nums.size(); for (int i = 0; i < n; i++) { int left = k - nums[i]; if (mp[left] > 0) // 1 pair summing up to k found return true; } return false; } int main() { // ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif ll t = 1; cin >> t; while (t--) { int n, k; // n-->total number of elements, k-->sum of two numbers cin >> n >> k; vector a(n); unordered_map mp; // stores the frequency of all the elements for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; } if (sumUp(mp, k, a)) cout << "YES" << nl; else cout << "NO" << nl; } }