import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {public static void main(String[] args) throws Exception {new Solve();}}

class Solve { public Solve() throws Exception {solve();}

    void solve() throws Exception {
        int n = NI();
        int m = NI();
        int k = NI();
        boolean[][] a = new boolean[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                a[i][j] = NI() == 1;
        int[] res = new int[n];
        for (int i = 0; i < k; i++) {
            int c = NI() - 1;
            int t = NI() - 1;
            for (int j = 0; j < n; j++)
                if (a[j][t] && j != c)
                    res[j]++;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
            sb.append(res[i]).append(" ");
        System.out.println(sb.toString());
    }

    class Cell {
        int i;
        boolean blocked;
    }

    static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st = new StringTokenizer("");
    static Scanner sc = new Scanner(System.in);
    int min(int i1,int i2){return i1<i2?i1:i2;}
    long min(long i1,long i2){return i1<i2?i1:i2;}
    int max(int i1,int i2){return i1>i2?i1:i2;}
    long max(long i1,long i2){return i1>i2?i1:i2;}
    String NS()throws Exception{while(!st.hasMoreTokens())st=new StringTokenizer(stdin.readLine());return st.nextToken();}
    String NLn() throws Exception {return stdin.readLine();}
    int NI()throws Exception{return Integer.parseInt(NS());}
    long NL()throws Exception{return Long.parseLong(NS());}
    double ND()throws Exception{return Double.parseDouble(NS());}
    int abs(int x){return x<0?-x:x;}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {public static void main(String[] args) throws Exception {new Solve();}}

class Solve { public Solve() throws Exception {solve();}

    void solve() throws Exception {
        int n = NI();
        int m = NI();
        int k = NI();
        String[] a = new String[n];
       // boolean[][] a = new boolean[n][m];
        for (int i = 0; i < n; i++)
            //for (int j = 0; j < m; j++)
                a[i] = NS();
        int[] res = new int[n];
        for (int i = 0; i < k; i++) {
            int c = NI();
            int t = NI() - 1;
            for (int j = 0; j < n; j++)
                if (a[j].charAt(t * 2) == '1' && j != c)
                    res[j]++;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
            sb.append(res[i]).append(" ");
        System.out.println(sb.toString());
    }

    class Cell {
        int i;
        boolean blocked;
    }

    static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st = new StringTokenizer("");
    static Scanner sc = new Scanner(System.in);
    int min(int i1,int i2){return i1<i2?i1:i2;}
    long min(long i1,long i2){return i1<i2?i1:i2;}
    int max(int i1,int i2){return i1>i2?i1:i2;}
    long max(long i1,long i2){return i1>i2?i1:i2;}
    String NS()throws Exception{while(!st.hasMoreTokens())st=new StringTokenizer(stdin.readLine());return st.nextToken();}
    String NLn() throws Exception {return stdin.readLine();}
    int NI()throws Exception{return Integer.parseInt(NS());}
    long NL()throws Exception{return Long.parseLong(NS());}
    double ND()throws Exception{return Double.parseDouble(NS());}
    int abs(int x){return x<0?-x:x;}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {public static void main(String[] args) throws Exception {new Solve();}}

class Solve { public Solve() throws Exception {solve();}

    void solve() throws Exception {
        int n = NI();
        int m = NI();
        int k = NI();
        String[] a = new String[n];
       // boolean[][] a = new boolean[n][m];
        for (int i = 0; i < n; i++)
            //for (int j = 0; j < m; j++)
                a[i] = NS();
        int[] res = new int[n];
        for (int i = 0; i < k; i++) {
            int c = NI() - 1;
            int t = NI() - 1;
            for (int j = 0; j < n; j++)
                if (a[j].charAt(t * 2 - 1) == '1' && j != c)
                    res[j]++;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
            sb.append(res[i]).append(" ");
        System.out.println(sb.toString());
    }

    class Cell {
        int i;
        boolean blocked;
    }

    static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st = new StringTokenizer("");
    static Scanner sc = new Scanner(System.in);
    int min(int i1,int i2){return i1<i2?i1:i2;}
    long min(long i1,long i2){return i1<i2?i1:i2;}
    int max(int i1,int i2){return i1>i2?i1:i2;}
    long max(long i1,long i2){return i1>i2?i1:i2;}
    String NS()throws Exception{while(!st.hasMoreTokens())st=new StringTokenizer(stdin.readLine());return st.nextToken();}
    String NLn() throws Exception {return stdin.readLine();}
    int NI()throws Exception{return Integer.parseInt(NS());}
    long NL()throws Exception{return Long.parseLong(NS());}
    double ND()throws Exception{return Double.parseDouble(NS());}
    int abs(int x){return x<0?-x:x;}
}


import java.io.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;

public class CodeForces {

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		long arr[] = new long[n];
		int msg[] = new int[m];
		Arrays.fill(arr, 0);
		Arrays.fill(msg, 0);

		Map<Integer, List<Integer>> hm = new HashMap<Integer, List<Integer>>();

		for (int i = 0; i < m; i++) {
			hm.put(i, new ArrayList<Integer>());
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (nextInt() == 1) {
					hm.get(j).add(i);
				}
			}
		}

		for (int i = 0; i < k; i++) {
			int s = nextInt() - 1;
			int c = nextInt() - 1;
			msg[c]++;
			arr[s]--;
		}

		for (int i = 0, l = msg.length; i < l; i++) {
			List<Integer> tl = hm.get(i);
			for (int s : tl) {
				arr[s] += msg[i];
			}
		}

		StringBuffer sb = new StringBuffer();
		sb.append(arr[0]);
		for (int i = 1, l = arr.length; i < l; i++) {
			sb.append(" ").append(Math.max(0, arr[i]));
		}

		System.out.println(sb.toString());
	}

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

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader(
						"C:\\work\\javaprojects\\CodeForces\\SCC.txt"));
				// out = new PrintWriter(new BufferedWriter(new FileWriter(
				// "output.txt")));
				// out = new PrintWriter(System.out);
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;

			// long time = System.currentTimeMillis();
			solve();
			// out.println(System.currentTimeMillis() - time);
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.io.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;

public class CodeForces {

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		long arr[] = new long[n];
		Arrays.fill(arr,0);

		int chat[][] = new int[m][n];

		for (int i = 0, l = chat.length; i < l; i++) {
			Arrays.fill(chat[i], 0);
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				chat[j][i]=nextInt();
			}
		}

		for (int i = 0; i < k; i++) {
			int s = nextInt()-1;
			int c = nextInt()-1;
			for (int j = 0; j < n; j++) {
				if(j!=s && chat[c][j]==1){
					arr[j]++;
				}
			}
		}

		StringBuffer sb = new StringBuffer();
		sb.append(arr[0]);
		for (int i = 1, l = arr.length; i < l; i++) {
			sb.append(" ").append(arr[i]);
		}

		System.out.println(sb.toString());

	}

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

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader(
						"C:\\work\\javaprojects\\CodeForces\\SCC.txt"));
				// out = new PrintWriter(new BufferedWriter(new FileWriter(
				// "output.txt")));
				// out = new PrintWriter(System.out);
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;

			// long time = System.currentTimeMillis();
			solve();
			// out.println(System.currentTimeMillis() - time);
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.io.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;

public class CodeForces {

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		long arr[] = new long[n];
		Arrays.fill(arr, 0);

		Map<Integer, List<Integer>> hm = new HashMap<Integer, List<Integer>>();

		for (int i = 0; i < m; i++) {
			hm.put(i, new ArrayList<Integer>());
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (nextInt() == 1) {
					hm.get(j).add(i);
				}
			}
		}

		for (int i = 0; i < k; i++) {
			int s = nextInt() - 1;
			int c = nextInt() - 1;
			List<Integer> ls = hm.get(c);
			for (int t : ls) {
				if(s!=t) {
					arr[t]++;
				}
			}
		}

		StringBuffer sb = new StringBuffer();
		sb.append(arr[0]);
		for (int i = 1, l = arr.length; i < l; i++) {
			sb.append(" ").append(arr[i]);
		}

		System.out.println(sb.toString());

	}

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

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader(
						"C:\\work\\javaprojects\\CodeForces\\SCC.txt"));
				// out = new PrintWriter(new BufferedWriter(new FileWriter(
				// "output.txt")));
				// out = new PrintWriter(System.out);
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;

			// long time = System.currentTimeMillis();
			solve();
			// out.println(System.currentTimeMillis() - time);
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


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

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

public class cf413b {

    static BufferedReader br;
    static Scanner sc;
    static PrintWriter out;

    public static void initA() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            sc = new Scanner(System.in);
            out = new PrintWriter(System.out);
        } catch (Exception e) {
        }
    }

    static boolean next_permutation(Integer[] p) {
        for (int a = p.length - 2; a >= 0; --a) {
            if (p[a] < p[a + 1]) {
                for (int b = p.length - 1;; --b) {
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static Long[] getLongArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static String[] getStringArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            String temp2[] = new String[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = (temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static void print(String s, Object... a) {
        out.printf(s, a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static void main(String[] ar) {
        initA();
        cf413b c = new cf413b();
        c.solve();
        out.flush();
    }

    void solve() {
        Integer temp[] = getIntArr();
        int n = temp[0], m = temp[1], k = temp[2];

        long total[] = new long[m];

        boolean gabung[][] = new boolean[n][m];

        for(int i = 0;i<n;i++){
            Integer x[] = getIntArr();
            int t = 0;
            for(int j =0 ;j<m;j++){
                if(x[j]==1){
                    total[j]++;
                    gabung[i][j] = true;
                }
            }
        }
        long omong[] = new long[m];

        long om[] = new long[n];
        for(int i =0 ;i<k;i++){
            Integer x[] = getIntArr();
            int a = x[0]-1, b = x[1]-1;
            omong[b]++;
            om[a]++;
        }
        for(int i = 0;i<n;i++){
            long res = -om[i];
            for(int j =0 ;j<m;j++){
                if(gabung[i][j])
                res+= (omong[j]);
            }

            if(i > 0) print("%c",' ');
            print("%d",res);
        }
        print("");

    }
}


import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

/*
  br = new BufferedReader(new FileReader("input.txt"));
  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
  br = new BufferedReader(new InputStreamReader(System.in));
  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++) {
			int n = readInt();
			int m = readInt();
			int qqq = readInt();
			boolean[][] grid = new boolean[n][m];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					grid[i][j] = readInt() == 1;
				}
			}
			int[] ret = new int[n];
			int[] count = new int[m];
			while(qqq-- > 0) {
				ret[readInt()-1]--;
				count[readInt()-1]++;
			}
			for(int i = 0; i < m; i++) {
				for(int j = 0; j < n; j++) {
					if(grid[j][i]) {
						ret[j] += count[i];
					}
				}
			}
			for(int out: ret) {
				pw.print(out + " ");
			}
			pw.println();
		}
		exitImmediately();
	}

	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

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

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

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

	private static String nextLine() throws IOException  {
		if(!br.ready()) {
			exitImmediately();
		}
		st = null;
		return br.readLine();
	}

	private static String nextToken() throws IOException  {
		while(st == null || !st.hasMoreTokens())  {
			if(!br.ready()) {
				exitImmediately();
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}


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

public class Main {

    final int INF = 1000000000;
    final int MAXN = 20000 + 5;
    final int MAXC = 10000 + 5;
    final double EPS = 1e-7;
    final int MODULO = 1000000007;

    Scanner input = new Scanner(System.in);
    BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer ST;

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        new Main().run();
    }

    int n, m, k;
    int[] count;
    int[][] chat;
    int[][] messages;
    int[] res;
    void run() throws IOException {
        ST = new StringTokenizer(inp.readLine());
        n = Integer.parseInt((String)ST.nextElement());
        m = Integer.parseInt((String)ST.nextElement());
        k = Integer.parseInt((String)ST.nextElement());
        chat = new int[m][n];
        messages = new int[m][n];
        count = new int[m];
        Arrays.fill(count, 0);
        for (int i = 0; i < n; ++i) {
            ST = new StringTokenizer(inp.readLine());
            int state;
            for (int p = 0; p < m; ++p) {
                state = Integer.parseInt((String)ST.nextElement());
                if (state == 1) {
                    chat[p][count[p]] = i;
                    messages[p][count[p]++] = 0;
                }
            }
        }
        for (int i = 0; i < k; ++i) {
            int x, y;
            ST = new StringTokenizer(inp.readLine());
            x = Integer.parseInt((String)ST.nextElement()) - 1;
            y = Integer.parseInt((String)ST.nextElement()) - 1;
            int index = Arrays.binarySearch(chat[y], 0, count[y], x);
            messages[y][index]++;
        }
//      for (int i = 0; i < m; ++i) {
//          for (int p = 0; p < messages.get(i).size(); ++p) {
//              out.print(messages.get(i).get(p) + " ");
//          }
//          out.println();
//      }
        for (int i = 0; i < m; ++i) {
            for (int p = 1; p < count[i]; ++p) {
                messages[i][p] += messages[i][p - 1];
            }
        }
        res = new int[n];
        Arrays.fill(res, 0);
        for (int i = 0; i < m; ++i) {
            res[chat[i][0]] += messages[i][count[i] - 1] - messages[i][0];
            for (int p = 1; p < count[i]; ++p) {
                res[chat[i][p]] += messages[i][p - 1] + messages[i][count[i] - 1] - messages[i][p];
            }
        }
//      for (int i = 0; i < m; ++i) {
//          for (int p = 0; p < messages.get(i).size(); ++p) {
//              out.print(messages.get(i).get(p) + " ");
//          }
//          out.println();
//      }
        for (int i = 0; i < n; ++i) {
            out.print(res[i] + " ");
        }
        out.close();
    }
}


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

public class Main {

    final int INF = 1000000000;
    final int MAXN = 20000 + 5;
    final int MAXC = 10000 + 5;
    final double EPS = 1e-7;
    final int MODULO = 1000000007;

    Scanner input = new Scanner(System.in);
    BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer ST;

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        new Main().run();
    }

    int n, m, k;
    ArrayList<ArrayList<Integer> > chat;
    ArrayList<ArrayList<Integer> > messages;
    int[] res;
    void run() throws IOException {
        ST = new StringTokenizer(inp.readLine());
        n = Integer.parseInt((String)ST.nextElement());
        m = Integer.parseInt((String)ST.nextElement());
        k = Integer.parseInt((String)ST.nextElement());
        chat = new ArrayList<ArrayList<Integer> >();
        messages = new ArrayList<ArrayList<Integer> >();
        for (int i = 0; i < m; ++i) {
            chat.add(new ArrayList<Integer>());
            messages.add(new ArrayList<Integer>());
        }
        for (int i = 0; i < n; ++i) {
            ST = new StringTokenizer(inp.readLine());
            int state;
            for (int p = 0; p < m; ++p) {
                state = Integer.parseInt((String)ST.nextElement());
                if (state == 1) {
                    chat.get(p).add(i);
                    messages.get(p).add(0);
                }
            }
        }
        for (int i = 0; i < k; ++i) {
            int x, y;
            ST = new StringTokenizer(inp.readLine());
            x = Integer.parseInt((String)ST.nextElement()) - 1;
            y = Integer.parseInt((String)ST.nextElement()) - 1;
            int index = Arrays.binarySearch(chat.get(y).toArray(), x);
            messages.get(y).set(index, messages.get(y).get(index) + 1);
        }
//      for (int i = 0; i < m; ++i) {
//          for (int p = 0; p < messages.get(i).size(); ++p) {
//              out.print(messages.get(i).get(p) + " ");
//          }
//          out.println();
//      }
        for (int i = 0; i < m; ++i) {
            for (int p = 1; p < messages.get(i).size(); ++p) {
                messages.get(i).set(p, messages.get(i).get(p) + messages.get(i).get(p - 1));
            }
        }
        res = new int[n];
        Arrays.fill(res, 0);
        for (int i = 0; i < m; ++i) {
            res[chat.get(i).get(0)] += messages.get(i).get(chat.get(i).size() - 1) - messages.get(i).get(0);
            for (int p = 1; p < chat.get(i).size(); ++p) {
                res[chat.get(i).get(p)] += messages.get(i).get(p - 1) + messages.get(i).get(chat.get(i).size() - 1) - messages.get(i).get(p);
            }
        }
//      for (int i = 0; i < m; ++i) {
//          for (int p = 0; p < messages.get(i).size(); ++p) {
//              out.print(messages.get(i).get(p) + " ");
//          }
//          out.println();
//      }
        for (int i = 0; i < n; ++i) {
            out.print(res[i] + " ");
        }
        out.close();
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * 6
 * 1 0
 * 0 0
 * 0 0
 * 1 1
 * 0 1
 * 1 1
 *
 * @author pttrung
 */
public class B {

    public static boolean circle;
    public static int[] dp;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out;

        Scanner in = new Scanner();
        //out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        ArrayList<Integer>[] map = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            map[i] = new ArrayList();
            for (int j = 0; j < m; j++) {
                int val = in.nextInt();
                if (val == 1) {
                    map[i].add(j);
                }
            }
        }
        int[] mess = new int[m];
        int[] count = new int[n];
        for (int i = 0; i < k; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            count[a]--;
            mess[b]++;
        }
        for(int i = 0; i < n; i++){
            int a = count[i];
            for(int j : map[i]){
                a += mess[j];
            }
            out.print(a + " ");
        }

        out.close();
    }

    public static void builder(int index, String val, Node node) {
        if (index == val.length()) {
            return;
        }
    }

    public static class Node {

        int val;
        Node[] next = new Node[26];

        public Node(int val) {
            this.val = val;
        }
    }

    public static Line getLine(Point a, Point b) {
        int c = (a.x - b.x);
        int d = (a.y - b.y);
        if (c == 0) {
            return new Line(1, 0, -a.x);
        } else if (d == 0) {
            return new Line(0, 1, -a.y);
        } else {
            double rate = (double) (-d) / c;

            double other = ((double) rate * a.x) + a.y;
            //System.out.println(a + "|" + b + ": " + rate + " " + other);
            return new Line(rate, 1, -other);
        }
    }

    public static class Line {

        double a, b, c;

        public Line(double a, double b, double c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 47 * hash + (int) (Double.doubleToLongBits(this.a) ^ (Double.doubleToLongBits(this.a) >>> 32));
            hash = 47 * hash + (int) (Double.doubleToLongBits(this.b) ^ (Double.doubleToLongBits(this.b) >>> 32));
            hash = 47 * hash + (int) (Double.doubleToLongBits(this.c) ^ (Double.doubleToLongBits(this.c) >>> 32));
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Line other = (Line) obj;
            if (Double.doubleToLongBits(this.a) != Double.doubleToLongBits(other.a)) {
                return false;
            }
            if (Double.doubleToLongBits(this.b) != Double.doubleToLongBits(other.b)) {
                return false;
            }
            if (Double.doubleToLongBits(this.c) != Double.doubleToLongBits(other.c)) {
                return false;
            }
            return true;
        }

        @Override
        public String toString() {
            return a + " " + b + " " + c;
        }
    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    public static double dist(Point a, Point b) {
        double val = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(val);
    }

    public static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return x + " " + y;
        }
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static long pow(int a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new FileReader(new File("output.txt")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
public class B {
    public static void main(String[] args) throws IOException {
        BufferedReader input =
			new BufferedReader(new InputStreamReader(System.in));
		String[] temp = input.readLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int m = Integer.parseInt(temp[1]);
		int k = Integer.parseInt(temp[2]);
		long[][] M = new long[n][m];
		for (int i = 0; i < n; i++) {
		    temp = input.readLine().split(" ");
		    for (int j = 0; j < m; j++) {
		        if (temp[j].equals("0"))
		            M[i][j] = 0;
		        else M[i][j] = 1;
		    }
		}
		long[][] N = new long[n][m];
		for (int i = 0; i < k; i++) {
		    temp = input.readLine().split(" ");
		    int x = Integer.parseInt(temp[0]);
		    int y = Integer.parseInt(temp[1]);
		    N[x-1][y-1] = N[x-1][y-1] + 1l;
		}
		long[] sum = new long[m];
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < m; j++) {
		        sum[j] += N[i][j];
		    }
		}
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < m; j++) {
		        N[i][j] = sum[j] - N[i][j];
		    }
		}
		for (int i = 0; i < n; i++) {
		    long sumTemp = 0l;
		    for (int j = 0; j < m; j++) {
		        N[i][j] = (long)M[i][j] * N[i][j];
		        sumTemp += N[i][j];
		    }
		    if (i < n - 1) System.out.print(sumTemp + " ");
		    else System.out.println(sumTemp);
		}
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class coderstrike_2_b {
	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
public static void main(String[] args)throws IOException {
	br=new BufferedReader(new InputStreamReader(System.in));
	pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	int n=nextInt(),m=nextInt(),k=nextInt(),a[][]=new int[n+1][m+1];
	for (int i = 1; i <=n; i++) {
		for (int j = 1; j <=m; j++) {
			a[i][j]=nextInt();
		}
	}
	int d1[]=new int[n+1],d2[]=new int[m+1];
	for (int i = 1; i <=k; i++) {
		int x=nextInt(),y=nextInt();
		d1[x]++;
		d2[y]++;
	}
	for (int i = 1; i <=n; i++) {
		int ans=0;
		for (int j = 1; j <=m; j++) {
			if(a[i][j]==1)
				ans+=d2[j];
		}
	ans-=d1[i];
	pw.print(ans+" ");
	}
	pw.close();
	}
private static int nextInt()throws IOException{
	return Integer.parseInt(next());
}
private static long nextLong()throws IOException{
	return Long.parseLong(next());
}
private static double nextDouble()throws IOException{
	return Double.parseDouble(next());
}
private static String next()throws IOException {
	while (st==null||!st.hasMoreTokens())
	 st=new StringTokenizer(br.readLine());
	return st.nextToken();
}
}


#include<iostream>
#include<fstream>
#include<string.h>
#include <algorithm>
#define N 200000
using namespace std;
struct node
   {
        int s,e;
   }Y[N+10];
bool cmp(node x,node y)
     {
         return x.e>y.e;
     }
int num_recieve(int* a ,int n)
{
	return 0;
}
int main()
{
	//freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);
	int i,j,n,m,k,a[20000][10],num1[10],num2[20000];
	memset(num1,0,sizeof(num1));memset(num2,0,sizeof(num2));
	cin>>n>>m>>k;
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			cin>>a[i][j];
	for(i=0;i<k;i++)
		cin>>Y[i].s>>Y[i].e;
	for(i=0;i<m;i++)
		for(j=0;j<k;j++)
		{
			if(Y[j].e==i+1)
				num1[i]++;
		}
	for(i=0;i<n;i++)
		for(j=0;j<k;j++)
		{
			if(Y[j].s==i+1)
				num2[i]++;
		}
	for(i=0;i<n;i++)
	{
		int count=0;
		for(j=0;j<m;j++)
		{
			if(a[i][j]==1)
			{
				count+=num1[j];
			}
		}
		cout<<count-num2[i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include<iostream>
#include<fstream>
#include<string.h>
#define N 200000
using namespace std;
struct node
   {
        int s,e;
   }Y[N+10];
int main()
{
	//freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);
	int i,j,n,m,k,a[20000][10];
	cin>>n>>m>>k;
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			cin>>a[i][j];
	for(i=0;i<k;i++)
		cin>>Y[i].s>>Y[i].e;

	for(i=0;i<n;i++)
	{
		int count=0;
		for(j=0;j<m;j++)
		{
			if(a[i][j]==1)
			{
				for(int c=0;c<k;c++)
				{
					if(Y[c].s!=i+1 && Y[c].e==j+1)
					    count++;
				}
			}
		}
		cout<<count<<" ";
	}
	cout<<endl;
	return 0;
}


#include<iostream>
#include<fstream>
#include<string.h>
#include <algorithm>
#define N 200000
using namespace std;
struct node
   {
        int s,e;
   }Y[N+10];
bool cmp(node x,node y)
     {
         return x.e>y.e;
     }

int main()
{
	//freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);
	int i,j,n,m,k,a[20000][10],num1[10],num2[20000];
	memset(num1,0,sizeof(num1));memset(num2,0,sizeof(num2));
	cin>>n>>m>>k;
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			cin>>a[i][j];
	for(i=0;i<k;i++)
		cin>>Y[i].s>>Y[i].e;
	for(i=0;i<m;i++)
		for(j=0;j<k;j++)
		{
			if(Y[j].e==i+1)
				num1[i]++;
		}
	//sort(Y,Y+k,cmp);
	for(j=0;j<k;j++)
		{
			num2[Y[j].s-1]++;
		}
	for(i=0;i<n;i++)
	{
		int count=0;
		for(j=0;j<m;j++)
		{
			if(a[i][j]==1)
			{
				count+=num1[j];
			}
		}
		cout<<count-num2[i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int a[20000 + 100][100];
vector <int> v[10000];
map <int,int> m1;
map <int,int> person;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]==1)
			{
				v[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		m1[y]++;
		person[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		for(int j=0;j<v[i].size();j++)
		{
			ans=ans+m1[v[i][j]];
		}
		ans=ans-person[i];
		cout<<ans<<" ";
	}
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int a[100+ 10][100 + 10];
vector <int> v[1000];
map <int,int> m1;
map <int,int> person;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]==1)
			{
				v[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		m1[y]++;
		person[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		for(int j=0;j<v[i].size();j++)
		{
			ans=ans+m1[v[i][j]];
		}
		ans=ans-person[i];
		cout<<ans<<" ";
	}
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int a[20000 + 10][50];
vector <int> v[1000];
map <int,int> m1;
map <int,int> person;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]==1)
			{
				v[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		m1[y]++;
		person[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		for(int j=0;j<v[i].size();j++)
		{
			ans=ans+m1[v[i][j]];
		}
		ans=ans-person[i];
		cout<<ans<<" ";
	}
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int a[10000+ 10][10000 + 10];
vector <int> v[10000];
map <int,int> m1;
map <int,int> person;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]==1)
			{
				v[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		m1[y]++;
		person[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		for(int j=0;j<v[i].size();j++)
		{
			ans=ans+m1[v[i][j]];
		}
		ans=ans-person[i];
		cout<<ans<<" ";
	}
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int a[20000 + 100][100];
vector <int> v[20000 + 100];
map <int,int> m1;
map <int,int> person;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]==1)
			{
				v[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		m1[y]++;
		person[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		for(int j=0;j<v[i].size();j++)
		{
			ans=ans+m1[v[i][j]];
		}
		ans=ans-person[i];
		cout<<ans<<" ";
	}
	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int a[100+ 10][100 + 10];
vector <int> v[1000];
map <int,int> m1;
map <int,int> person;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]==1)
			{
				v[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		m1[y]++;
		person[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		for(int j=0;j<v[i].size();j++)
		{
			ans=ans+m1[v[i][j]];
		}
		ans=ans-person[i];
		cout<<ans<<endl;
	}

}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include <utility>

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define _with_file
#define TASK ""
#define forn(i, n) for(int i = 0; i < (int)n; ++i)

void quit();

using namespace std;

typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef pair <int, int> PII;
typedef pair <i64, i64> PII64;
typedef pair <ld, ld> PLL;

const ld PI = acos(-1);
const ld EPS = 1e-10;
double __t;

int n, m, k;
int ans[20100];
vector <int> chat[11];
bool inc[20010][11];
int sent[20100][11];
int mic[11];

int main()
{
    #ifdef local
        __t = clock();
        #ifndef _with_files
            freopen("z.in", "rt", stdin);
            freopen("z.out", "wt", stdout);
        #endif
    #endif
    #ifdef _with_files
        freopen(TASK".in", "rt", stdin);
        freopen(TASK".out", "wt", stdout);
    #endif
    char c;
    cin >> n >> m >> k;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < m; ++j)
        {
            cin >> c;
            if (c == '1')
            {
                //chat[j].pb(i);
                inc[i][j] = 1;
            }
        }
    }
    int x, y;
    for(int i = 0; i < k; ++i)
    {
        cin >> x >> y;
        --x; --y;
        if (inc[x][y])
        {
            sent[x][y]++;
            mic[y]++;
        }
    }
    for(int i = 0; i < n; ++i)
    {
        ans[i] = 0;
        for(int j = 0; j < m; ++j)
        {
            if (inc[i][j])
                ans[i] += mic[j] - sent[i][j];
        }
    }
    for(int i = 0; i < n; ++i)
        cout << ans[i] << ' ';
    quit();
}

void quit()
{
    #ifdef local
        cerr << "\nTOTAL TIME: "<< (clock() - __t)/1000.0 << " s\n";
    #endif
    exit(0);
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include <utility>

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define _with_file
#define TASK ""
#define forn(i, n) for(int i = 0; i < (int)n; ++i)

void quit();

using namespace std;

typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef pair <int, int> PII;
typedef pair <i64, i64> PII64;
typedef pair <ld, ld> PLL;

const ld PI = acos(-1);
const ld EPS = 1e-10;
double __t;

int n, m, k;
int ans[20100];
vector <int> chat[11];
bool inc[20010][11];

int main()
{
    #ifdef local
        __t = clock();
        #ifndef _with_files
            freopen("z.in", "rt", stdin);
            freopen("z.out", "wt", stdout);
        #endif
    #endif
    #ifdef _with_files
        freopen(TASK".in", "rt", stdin);
        freopen(TASK".out", "wt", stdout);
    #endif
    char c;
    cin >> n >> m >> k;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < m; ++j)
        {
            cin >> c;
            if (c == '1')
            {
                chat[j].pb(i);
                inc[i][j] = 1;
            }
        }
    }
    int x, y;
    for(int i = 0; i < k; ++i)
    {
        cin >> x >> y;
        --x; --y;
        if (inc[x][y])
        {
            for(int j = 0; j < (int)chat[y].size(); ++j)
            {
                if (chat[y][j] != x)
                    ans[chat[y][j]]++;
            }
        }
    }
    for(int i = 0; i < n; ++i)
        cout << ans[i] << ' ';
    quit();
}

void quit()
{
    #ifdef local
        cerr << "\nTOTAL TIME: "<< (clock() - __t)/1000.0 << " s\n";
    #endif
    exit(0);
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */ "020", "022", "200", "220", "202", "222"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */ "020", "022", "200", "220", "202"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */ "002", "020", "022", "200", "220", "202", "222"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */  "022", "220", "202", "222"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            rep(j, 0, str.size()){
                if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                    ans = true;
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */ "022", "220"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */ "022", "200", "220", "202"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */ "022", "220", "202", "222"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int MAXN = 100 * 1000 + 1;
const std::vector<std::string> str = {"011", "012", "021", "101", "102", "110", "111", "112", "120", "121", "122", "201", "210", "211", "212", "221", /* plus */  "022", "220", "202", "222"};
using namespace std;

int n, k;
int process(){
    string s = "";
    cin >> n >> k;
    int exist = 0;
    rep(i, 0, n){
        int x; cin >> x;
        if(x < k) s += '0';
        else if(x == k){ s += '1'; exist++;}
        else s += '2';
    }
    if(exist == 0) return 0;
    if(n == 1) return 1;
    bool ans = false;
    if(n <= 2){
        if(strcmp(s.c_str(), "01") == 0 || strcmp(s.c_str(), "10") == 0) ans = false;
        else ans = true;
    }else{
        rep(i, 0, (int) s.size() - 2){
            if(s[i] == '1' || s[i+1] == '1' || s[i+2] == '1'){
                rep(j, 0, str.size()){
                    if(strcmp(str[j].c_str(), s.substr(i, 3).c_str()) == 0){
                        ans = true;
                    }
                }
            }
        }
    }
    if(ans)return 1;
    else return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tc; cin >> tc;
    while(tc--){
        if(process())cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


/*
+----------------------------------------------------------------+
| In the name of Allah, the most Gracious and the most Merciful. |
+----------------------------------------------------------------+
Our hearts quake with fear of you
Our hearts wake with love for you
And to Islam we must be true
In everything we think and do.
--------------------------------
When your heart is breaking
And your pain makes you fall
Remember just remember
Allah Sees it all.
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;

const int N = 3e5 + 100;
const int inf = 1e9 + 7;

int main(){
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while( t -- ){
        int n, k;
        cin >> n >> k;
        int a[n+1] = {};
        for( int i = 1; i <= n; i ++ ){
            cin >> a[i];
        }
        if( n == 1 && a[1] == k ){
            cout <<"yes\n";
            continue;
        }
        string ans = "no";
        for( int i = 1; i < n; i ++ ){
            if( a[i] == a[i+1] && a[i] == k) ans = "yes";
            if( a[i] == k && a[i+1] > k ) ans = "yes";
            if( a[i] > k && a[i+1] == k ) ans = "yes";
        }
        int cnt = 0, cntk = 0, l = 1, r = 1;
        while( r <= n){
            if( a[r] > k ) cnt++;
            if( a[r] < k ) cnt --;
            if( a[r] == k )cnt++, cntk++;
            if( r-l+1>1 && cnt >= 1 && cntk ){
                ans = "yes";
                break;
            }r++;
            if( cnt < 0 ){
                l = r;
                cntk = 0;
            }
        }
        cout << ans << "\n";
    }
}


/*
+----------------------------------------------------------------+
| In the name of Allah, the most Gracious and the most Merciful. |
+----------------------------------------------------------------+
Our hearts quake with fear of you
Our hearts wake with love for you
And to Islam we must be true
In everything we think and do.
--------------------------------
When your heart is breaking
And your pain makes you fall
Remember just remember
Allah Sees it all.
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;

const int N = 3e5 + 100;
const int inf = 1e9 + 7;

int main(){
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while( t -- ){
        int n, k;
        cin >> n >> k;
        int a[n+2] = {}, exist = 0;
        for( int i = 1; i <= n; i ++ ){
            cin >> a[i];
            if( a[i] == k ) exist = 1;
        }
        string ans = "no";
        for( int i = 1; i < n; i ++ ){
            if( a[i] >= k && a[i+1] >= k && exist ) ans = "yes";
            if( a[i] >= k && (i<=n-2) && a[i+2] >= k && exist ) ans="yes";
        }if( n == 1 && a[1] == k ) ans = "yes";
        cout << ans << endl;
    }
}


/*
+----------------------------------------------------------------+
| In the name of Allah, the most Gracious and the most Merciful. |
+----------------------------------------------------------------+
Our hearts quake with fear of you
Our hearts wake with love for you
And to Islam we must be true
In everything we think and do.
--------------------------------
When your heart is breaking
And your pain makes you fall
Remember just remember
Allah Sees it all.
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;

const int N = 3e5 + 100;
const int inf = 1e9 + 7;

int main(){
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while( t -- ){
        int n, k;
        cin >> n >> k;
        int a[n+1] = {}, cnt[n+2] = {}, qnt[n+2] = {}, right[2*n+2] = {}, left[2*n+2] = {};
        for( int i = 1; i <= n; i ++ ){
            cin >> a[i];
            cnt[i] = cnt[i-1];
            if( a[i] >= k ) cnt[i] ++;
            else cnt[i] --;
            right[cnt[i]+n] = i;
        }
        fill(left, left + 2*n+2, 1e9);
        for( int i =n; i >= 1; i -- ){
            qnt[i] = qnt[i+1];
            if( a[i] >= k ) qnt[i] ++;
            else qnt[i] --;
            left[qnt[i]+n] = i;
        }
        if( n == 1 && a[1] == k ){
            cout <<"yes\n";
            continue;
        }
        for( int i = 2*n-1; i >= 0; i -- ){
            right[i] = max( right[i], right[i+1] );
            left[i] = min( left[i], left[i+1] );
        }

        string ans = "no";
        for( int i = 1; i <= n; i ++ ){
            if( a[i] == k && i < right[cnt[i]+n] )ans = "yes";
            if( a[i] == k && i > left[qnt[i]+n] )ans = "yes";
        }
        cout << ans << "\n";
        /*
        cout << "cnt   : "; for( int i = 1; i <= n; i ++ ) cout << cnt[i] << ' ';
        cout << endl;
        cout << "right : "; for( int i = 1; i <= 2*n; i ++ ) cout << right[i] << ' ';
        cout << endl;
        cout << "qnt   : "; for( int i = 1; i <= n; i ++ ) cout << qnt[i] << ' ';
        cout << endl;
        cout << "left  : "; for( int i = 1; i <= 2*n; i ++ ) cout << left[i] << ' ';
        cout << endl;
        */
    }
}


/*
+----------------------------------------------------------------+
| In the name of Allah, the most Gracious and the most Merciful. |
+----------------------------------------------------------------+
Our hearts quake with fear of you
Our hearts wake with love for you
And to Islam we must be true
In everything we think and do.
--------------------------------
When your heart is breaking
And your pain makes you fall
Remember just remember
Allah Sees it all.
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;

const int N = 3e5 + 100;
const int inf = 1e9 + 7;

int main(){
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while( t -- ){
        int n, k;
        cin >> n >> k;
        int a[n+1] = {};
        for( int i = 1; i <= n; i ++ ){
            cin >> a[i];
        }
        if( n == 1 && a[1] == k ){
            cout <<"yes\n";
            continue;
        }
        string ans = "no";
        int cnt = 0, cntk = 0, l = 1, r = 1;
        while( r <= n){
            //cout << l << ' '<< r << ' ' << cnt << ' '<< cntk << endl;
            if( a[r] > k ) cnt++;
            if( a[r] < k ) cnt --;
            if( a[r] == k )cnt++, cntk++;
            if( r-l+1>1 && cnt >= 1 && cntk ){
                ans = "yes";
                break;
            }r++;
            if( cnt < 0 ){
                cnt = 0;
                l = r;
                cntk = 0;
            }
        }
        cout << ans << "\n";
    }
}


#include <bits/stdc++.h>
/*
 * autor:Yuan-NEU
 * Email:yuanyanghao2022@163.com
 * Time: 2020/09/06 13:35:54
 */
#define pcc pair<char, char>
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for (int i = x; i < y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
#define rep0(i, n) for (int i = 0; i < (n); i++)
#define per0(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 6e6 + 10;
const int MAX = 1e5;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f;
ll qpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
/***************main****************/
ll T = 1;
ll m, n;
int a[100005];
int main() {
  T = read();
  while (T--) {
    int k;
    n = read();
    k = read();
    int x = 0;
    rep(i, 0, n) {
      a[i] = read();
      x += (a[i] == k);
    }
    if (n == 1) {
      if (x)
        cout << "yes\n";
      else
        cout << "no\n";
    }
    if (!x) {
      cout << "no\n";
      continue;
    }
    bool f = false;
    rep(i, 0, n - 2) {
      int num = (a[i] >= k) + (a[i + 1] >= k) + (a[i + 2] >= k);
      if (num > 1) {
        f = true;
        break;
      }
    }
    if (f)
      cout << "yes\n";
    else
      cout << "no\n";
  }
  return 0;
}


#include <bits/stdc++.h>
/*
 * autor:Yuan-NEU
 * Email:yuanyanghao2022@163.com
 * Time: 2020/09/06 13:35:54
 */
#define pcc pair<char, char>
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for (int i = x; i < y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
#define rep0(i, n) for (int i = 0; i < (n); i++)
#define per0(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 6e6 + 10;
const int MAX = 1e5;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f;
ll qpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
/***************main****************/
ll T = 1;
ll m, n;
int a[100005];
int main() {
  T = read();
  while (T--) {
    int k;
    n = read();
    k = read();
    int x = 0;
    rep(i, 0, n) {
      a[i] = read();
      x += (a[i] == k);
    }
    if (n == 1) {
      if (x)
        cout << "yes\n";
      else
        cout << "no\n";
      continue;
    }
    if (!x) {
      cout << "no\n";
      continue;
    }
    bool f = false;
    rep(i, 0, n ) {
      int num = 0;
      for (int j = 0; j < 3 && i+j < n; j++) num += (a[i+j] >= k);
      if (num > 1) {
        f = true;
        break;
      }
    }
    if (f)
      cout << "yes\n";
    else
      cout << "no\n";
  }
  return 0;
}


#include <bits/stdc++.h>
/*
 * autor:Yuan-NEU
 * Email:yuanyanghao2022@163.com
 * Time: 2020/09/06 13:35:54
 */
#define pcc pair<char, char>
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for (int i = x; i < y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
#define rep0(i, n) for (int i = 0; i < (n); i++)
#define per0(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 6e6 + 10;
const int MAX = 1e5;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f;
ll qpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
/***************main****************/
ll T = 1;
ll m, n;
int a[100005];
int main() {
  T = read();
  while (T--) {
    int k;
    n = read();
    k = read();
    int x = 0;
    rep(i, 0, n) {
      a[i] = read();
      x += (a[i] == k);
    }
    if (n == 1) {
      if (x)
        cout << "yes\n";
      else
        cout << "no\n";
      continue;
    }
    if (!x) {
      cout << "no\n";
      continue;
    }
    bool f = false;
    rep(i, 0, n - 2) {
      int num = (a[i] >= k) + (a[i + 1] >= k) + (a[i + 2] >= k);
      if (num > 1) {
        f = true;
        break;
      }
    }
    if (f)
      cout << "yes\n";
    else
      cout << "no\n";
  }
  return 0;
}


#include <bits/stdc++.h>
/*
 * autor:Yuan-NEU
 * Email:yuanyanghao2022@163.com
 * Time: 2020/09/06 13:35:54
 */
#define pcc pair<char, char>
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for (int i = x; i < y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
#define rep0(i, n) for (int i = 0; i < (n); i++)
#define per0(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 6e6 + 10;
const int MAX = 1e5;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f;
ll qpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
/***************main****************/
ll T = 1;
ll m, n;
int a[100005];
int main() {
  T = read();
  while (T--) {
    int k;
    n = read();
    k = read();
    int x = 0;
    rep(i, 0, n) {
      a[i] = read();
      x += (a[i] == k);
    }
    if (n == 1) {
      if (x)
        cout << "yes\n";
      else
        cout << "no\n";
      continue;
    }
    if (!x) {
      cout << "no\n";
      continue;
    }
    bool f = false;
    rep(i, 0, n - 3) {
      int num = 0;
      for (int j = 0; j < 3 && j < n; j++) num += (a[j] >= k);
      if (num > 1) {
        f = true;
        break;
      }
    }
    if (f)
      cout << "yes\n";
    else
      cout << "no\n";
  }
  return 0;
}


#include <bits/stdc++.h>
/*
 * autor:Yuan-NEU
 * Email:yuanyanghao2022@163.com
 * Time: 2020/09/06 13:35:54
 */
#define pcc pair<char, char>
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for (int i = x; i < y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
#define rep0(i, n) for (int i = 0; i < (n); i++)
#define per0(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 6e6 + 10;
const int MAX = 1e5;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f;
ll qpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
/***************main****************/
ll T = 1;
ll m, n;
int a[100005];
int main() {
  T = read();
  while (T--) {
    int k;
    n = read();
    k = read();
    int x = 0;
    rep(i, 0, n) {
      a[i] = read();
      x += (a[i] == k);
    }
    if (n == 1) {
      if (x)
        cout << "yes\n";
      else
        cout << "no\n";
      continue;
    }
    if (!x) {
      cout << "no\n";
      continue;
    }
    bool f = false;
    rep(i, 0, n - 3) {
      int num = 0;
      for (int j = 0; j < 3 && j < n; j++) num += (a[i+j] >= k);
      if (num > 1) {
        f = true;
        break;
      }
    }
    if (f)
      cout << "yes\n";
    else
      cout << "no\n";
  }
  return 0;
}


#include <bits/stdc++.h>
/*
 * autor:Yuan-NEU
 * Email:yuanyanghao2022@163.com
 * Time: 2020/09/06 13:35:54
 */
#define pcc pair<char, char>
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for (int i = x; i < y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
#define rep0(i, n) for (int i = 0; i < (n); i++)
#define per0(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
using namespace std;

inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 6e6 + 10;
const int MAX = 1e5;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f;
ll qpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
/***************main****************/
ll T = 1;
ll m, n;
int a[100005];
int main() {
  T = read();
  while (T--) {
    int k;
    n = read();
    k = read();
    int x = 0;
    rep(i, 0, n) {
      a[i] = read();
      x += (a[i] == k);
    }
    if (n == 1) {
      if (x)
        cout << "yes\n";
      else
        cout << "no\n";
      continue;
    }
    if (!x) {
      cout << "no\n";
      continue;
    }
    bool f = false;
    rep(i, 0, n - 3) {
      int num = (a[i] >= k) + (a[i + 1] >= k) + (a[i + 2] >= k);
      if (num > 1) {
        f = true;
        break;
      }
    }
    if (f)
      cout << "yes\n";
    else
      cout << "no\n";
  }
  return 0;
}


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

#define ll long long

ll t;
ll n, k, x;
ll a, b;
bool tr, tr2;

int main() {
    cin >> t;

    while (t--) {
        cin >> n >> k;
        tr = false;
        tr2 = false;
        a = 0;
        b = 0;

        for (ll i = 0; i < n; i++) {
            cin >> x;

            if (x == k) tr = true;
            if (x < k) a++;
            if (x >= k) b++;
            if (a > b) {
                a = 0;
                b = 0;
            }

            if (b > a && b != 1) {
                tr2 = true;
            }
        }

        if (tr && tr2) {
            cout << "YES\n";
        }
        else if (n == 1 && tr) {
            cout << "YES\n";
        }
        else if (!tr) {
            cout << "NO\n";
        }
        else if (!tr2) {
            cout << "NO\n";
        }
    }

    return 0;
}


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

#define ll long long

ll t;
ll n, k, x;
ll a, b;
bool tr, tr2;

int main() {
    cin >> t;

    while (t--) {
        cin >> n >> k;
        tr = false;
        tr2 = false;
        a = 0;
        b = 0;

        for (ll i = 0; i < n; i++) {
            cin >> x;

            if (x == k) tr = true;
            if (x < k) a++;
            if (x >= k) b++;
            if (a > b) {
                a = 0;
                b = 0;
            }

            if (b > a && tr && b != 1 && !tr2) {
                cout << "YES\n";
                tr2 = true;
            }
        }

        if (n == 1 && tr) {
            cout << "YES\n";
        }
        else if ((!tr2 && tr) || (tr2 && !tr)) {
            cout << "NO\n";
        }
    }

    return 0;
}


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

int t;
int n, k, x;
int a, b;
bool tr, tr2;

int main() {
    cin >> t;

    while (t--) {
        cin >> n >> k;
        tr = false;
        tr2 = false;
        a = 0;
        b = 0;

        for (int i = 0; i < n; i++) {
            cin >> x;

            if (x == k) tr = true;
            if (x < k) a++;
            if (x >= k) b++;
            if (a > b) {
                a = 0;
                b = 0;
            }

            if (b > a && tr && b != 1) {
                cout << "YES\n";
                tr2 = true;
                break;
            }
        }

        if (n == 1 && tr) {
            cout << "YES\n";
        }
        else if (!tr2) {
            cout << "NO\n";
        }
    }

    return 0;
}


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

#define ll long long

ll t;
ll n, k, x;
ll a, b;
bool tr, tr2;

int main() {
    cin >> t;

    while (t--) {
        cin >> n >> k;
        tr = false;
        tr2 = false;
        a = 0;
        b = 0;

        for (ll i = 0; i < n; i++) {
            cin >> x;

            if (x == k) tr = true;
            if (x < k) a++;
            if (x >= k) b++;
            if (a > b) {
                a = 0;
                b = 0;
            }

            if (b > a && tr && b != 1) {
                cout << "YES\n";
                tr2 = true;
                break;
            }
        }

        if (n == 1 && tr) {
            cout << "YES\n";
        }
        else if (!tr2) {
            cout << "NO\n";
        }
    }

    return 0;
}


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

#define ll long long

ll t;
ll n, k, x;
ll a, b;
bool tr, tr2;

int main() {
    cin >> t;

    while (t--) {
        cin >> n >> k;
        tr = false;
        tr2 = false;
        a = 0;
        b = 0;

        for (ll i = 0; i < n; i++) {
            cin >> x;

            if (x == k) tr = true;
            if (x < k) a++;
            if (x >= k) b++;
            if (a > b) {
                a = 0;
                b = 0;
            }

            if (b > a && tr && b != 1 && !tr2) {
                cout << "YES\n";
                tr2 = true;
            }
        }

        if (n == 1 && tr) {
            cout << "YES\n";
        }
        else if (!tr2 || !tr) {
            cout << "NO\n";
        }
    }

    return 0;
}


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

#define ll long long

ll t;
ll n, k, x;
ll a, b;
bool tr, tr2;

int main() {
    cin >> t;

    while (t--) {
        cin >> n >> k;
        tr = false;
        tr2 = false;
        a = 0;
        b = 0;

        for (ll i = 0; i < n; i++) {
            cin >> x;

            if (x == k) tr = true;
            if (x < k) a++;
            if (x >= k) b++;
            if (a > b) {
                a = 0;
                b = 0;
            }

            if (b > a && tr && b != 1 && !tr2) {
                cout << "YES\n";
                tr2 = true;
            }
        }

        if (n == 1 && tr) {
            cout << "YES\n";
        }
        else if (!tr2) {
            cout << "NO\n";
        }
    }

    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int v[100002];
int main()
{
    int t,l,n,i,k,ok,kk;
    cin>>t;
    for(l=1;l<=t;l++)
    {
        cin>>n>>k;
        ok=0;
        for(i=1;i<=n;i++)
        {
            cin>>v[i];
            if(v[i]==k)
                ok=1;
        }
        if(ok==0)
            cout<<"no";
        else
        if(n==1)
            cout<<"yes";
        else
        if(n==2)
        {
            if(v[1]>=k&&v[2]>=k)
                cout<<"yes";
            else
                cout<<"no";
        }
        else
        {
            ok=0;
            for(i=2;i<=n-1;i++)
            {
                kk=0;
                if(v[i]>=k)
                    kk++;
                if(v[i+1]>=k)
                    kk++;
                if(v[i-1]>=k)
                    kk++;
                if(kk>=2)
                {
                    ok=1;
                    break;
                }
            }
            if(ok==1)
                cout<<"yes";
            else
                cout<<"no";
        }
        cout<<'\n';
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#define INF 1000000000
using namespace std;
int v[100002],s[100002],s2[100002];
int N=200004,aint[800020];
int query(int nod,int st,int dr,int left,int right)
{
    if(st==left&&dr==right)
        return aint[nod];
    else
    {
        int mij=(st+dr)/2;
        if(right<=mij)
            return query(2*nod,st,mij,left,right);
        else
        if(mij<left)
            return query(2*nod+1,mij+1,dr,left,right);
        else
            return min(query(2*nod,st,mij,left,mij),query(2*nod+1,mij+1,dr,mij+1,right));
    }
}

int query(int a,int b)
{
    return query(1,1,N,a+100002,b+100002);
}

void update(int nod,int st,int dr,int index,int value)
{
    if(st==dr)
        aint[nod]=min(value,aint[nod]);
    else
    {
        int mij=(st+dr)/2;
        if(index<=mij)
            update(2*nod,st,mij,index,value);
        else
            update(2*nod+1,mij+1,dr,index,value);
        aint[nod]=min(aint[2*nod],aint[2*nod+1]);
    }
}

void update(int a,int b)
{
    return update(1,1,N,a+100002,b);
}

int main()
{
    int t,l,n,i,k,ok,j;
    cin>>t;
    for(l=1;l<=t;l++)
    {
        cin>>n>>k;
        ok=0;
        for(i=1;i<=n;i++)
        {
            cin>>v[i];
            s2[i]=s2[i-1]+1;
            if(v[i]==k)
                ok=1,v[i]=0,s2[i]--;
            else
            if(v[i]<k)
                v[i]=-1;
            else
                v[i]=1;
        }
        if(ok==0)
            cout<<"no";
        else
        {
            if(n==1)
                cout<<"yes";
            else
            {
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                ok=0;
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                j=0;
                for(i=2;i<=n;i++)
                {
                    while(j<=i-2&&s2[i]-s2[j]<i-j)
                        update(s[j],j-s[j]-s2[j]),j++;
                    if(i-s[i]-s2[i]>=query(-100000,s[i]))
                        ok=1;
                }
                for(i=1;i<=n;i++)
                    v[i]=0-v[i];
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                j=0;
                for(i=2;i<=n;i++)
                {
                    while(j<=i-2&&s2[i]-s2[j]<i-j)
                        update(s[j],j-s[j]-s2[j]),j++;
                    if(i-s[i]-s2[i]>query(-100000,s[i]-1))
                        ok=1;
                }
                if(ok==1)
                    cout<<"yes";
                else
                    cout<<"no";
            }
        }
        cout<<'\n';
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#define INF 1000000000
using namespace std;
int v[100002],s[100002],s2[100002];
int N=400004,aint[1600020];
int query(int nod,int st,int dr,int left,int right)
{
    if(st==left&&dr==right)
        return aint[nod];
    else
    {
        int mij=(st+dr)/2;
        if(right<=mij)
            return query(2*nod,st,mij,left,right);
        else
        if(mij<left)
            return query(2*nod+1,mij+1,dr,left,right);
        else
            return min(query(2*nod,st,mij,left,mij),query(2*nod+1,mij+1,dr,mij+1,right));
    }
}

int query(int a,int b)
{
    return query(1,1,N,a+200002,b+200002);
}

void update(int nod,int st,int dr,int index,int value)
{
    if(st==dr)
        aint[nod]=value;
    else
    {
        int mij=(st+dr)/2;
        if(index<=mij)
            update(2*nod,st,mij,index,value);
        else
            update(2*nod+1,mij+1,dr,index,value);
        aint[nod]=min(aint[2*nod],aint[2*nod+1]);
    }
}

void update(int a,int b)
{
    return update(1,1,N,a+200002,b);
}

int main()
{
    int t,l,n,i,k,ok;
    cin>>t;
    for(l=1;l<=t;l++)
    {
        cin>>n>>k;
        ok=0;
        for(i=1;i<=n;i++)
        {
            cin>>v[i];
            s2[i]=s2[i-1]+1;
            if(v[i]==k)
                ok=1,v[i]=0,s2[i]--;
            else
            if(v[i]<k)
                v[i]=-1;
            else
                v[i]=1;
        }
        if(ok==0)
            cout<<"no";
        else
        {
            if(n==1)
                cout<<"yes";
            else
            {
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                ok=0;
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                update(0,0);//minim=0;
                for(i=2;i<=n;i++)
                {
                    if(i-s[i]-s2[i]>=query(-200000,s[i]))
                        ok=1;
                    update(s[i-1],i-1-s[i-1]-s2[i-1]);//minim=min(i-1-s[i-1],minim);
                }
                for(i=1;i<=n;i++)
                    v[i]=0-v[i];
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                update(0,0);//minim=0;
                for(i=2;i<=n;i++)
                {
                    if(i-s[i]-s2[i]>query(-200000,s[i]-1))
                        ok=1;
                    update(s[i-1],i-1-s[i-1]-s2[i-1]);//minim=min(i-1-s[i-1],minim);
                }
                if(ok==1)
                    cout<<"yes";
                else
                    cout<<"no";
            }
        }
        cout<<'\n';
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#define INF 1000000000
using namespace std;
int v[100002],s[100002],s2[100002];
int N=200004,aint[800020];
int query(int nod,int st,int dr,int left,int right)
{
    if(st==left&&dr==right)
        return aint[nod];
    else
    {
        int mij=(st+dr)/2;
        if(right<=mij)
            return query(2*nod,st,mij,left,right);
        else
        if(mij<left)
            return query(2*nod+1,mij+1,dr,left,right);
        else
            return min(query(2*nod,st,mij,left,mij),query(2*nod+1,mij+1,dr,mij+1,right));
    }
}

int query(int a,int b)
{
    return query(1,1,N,a+100002,b+100002);
}

void update(int nod,int st,int dr,int index,int value)
{
    if(st==dr)
        aint[nod]=value;
    else
    {
        int mij=(st+dr)/2;
        if(index<=mij)
            update(2*nod,st,mij,index,value);
        else
            update(2*nod+1,mij+1,dr,index,value);
        aint[nod]=min(aint[2*nod],aint[2*nod+1]);
    }
}

void update(int a,int b)
{
    return update(1,1,N,a+100002,b);
}

int main()
{
    int t,l,n,i,k,ok,j;
    cin>>t;
    for(l=1;l<=t;l++)
    {
        cin>>n>>k;
        ok=0;
        for(i=1;i<=n;i++)
        {
            cin>>v[i];
            s2[i]=s2[i-1]+1;
            if(v[i]==k)
                ok=1,v[i]=0,s2[i]--;
            else
            if(v[i]<k)
                v[i]=-1;
            else
                v[i]=1;
        }
        if(ok==0)
            cout<<"no";
        else
        {
            if(n==1)
                cout<<"yes";
            else
            {
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                ok=0;
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                j=0;
                for(i=2;i<=n;i++)
                {
                    while(j<=i-2&&s2[i]-s2[j]<i-j)
                        update(s[j],j-s[j]-s2[j]),j++;
                    if(i-s[i]-s2[i]>=query(-100000,s[i]))
                        ok=1;
                }
                for(i=1;i<=n;i++)
                    v[i]=0-v[i];
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                j=0;
                for(i=2;i<=n;i++)
                {
                    while(j<=i-2&&s2[i]-s2[j]<i-j)
                        update(s[j],j-s[j]-s2[j]),j++;
                    if(i-s[i]-s2[i]>query(-100000,s[i]-1))
                        ok=1;
                }
                if(ok==1)
                    cout<<"yes";
                else
                    cout<<"no";
            }
        }
        cout<<'\n';
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#define INF 1000000000
using namespace std;
int v[100002],s[100002],s2[100002];
int N=400004,aint[1600010];
int query(int nod,int st,int dr,int left,int right)
{
    if(st==left&&dr==right)
        return aint[nod];
    else
    {
        int mij=(st+dr)/2;
        if(right<=mij)
            return query(2*nod,st,mij,left,right);
        else
        if(mij<left)
            return query(2*nod+1,mij+1,dr,left,right);
        else
            return min(query(2*nod,st,mij,left,mij),query(2*nod+1,mij+1,dr,mij+1,right));
    }
}

int query(int a,int b)
{
    return query(1,1,N,a+200002,b+200002);
}

void update(int nod,int st,int dr,int index,int value)
{
    if(st==dr)
        aint[nod]=value;
    else
    {
        int mij=(st+dr)/2;
        if(index<=mij)
            update(2*nod,st,mij,index,value);
        else
            update(2*nod+1,mij+1,dr,index,value);
        aint[nod]=min(aint[2*nod],aint[2*nod+1]);
    }
}

void update(int a,int b)
{
    return update(1,1,N,a+200002,b);
}

int main()
{
    int t,l,n,i,k,ok;
    cin>>t;
    for(l=1;l<=t;l++)
    {
        cin>>n>>k;
        ok=0;
        for(i=1;i<=n;i++)
        {
            cin>>v[i];
            s2[i]=s2[i-1]+1;
            if(v[i]==k)
                ok=1,v[i]=0,s2[i]--;
            else
            if(v[i]<k)
                v[i]=-1;
            else
                v[i]=1;
        }
        if(ok==0)
            cout<<"no";
        else
        {
            if(n==1)
                cout<<"yes";
            else
            {
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                ok=0;
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                update(0,0);//minim=0;
                for(i=2;i<=n;i++)
                {
                    if(i-s[i]-s2[i]>=query(-100000,s[i]))
                        ok=1;
                    update(s[i-1],i-1-s[i-1]-s2[i-1]);//minim=min(i-1-s[i-1],minim);
                }
                for(i=1;i<=n;i++)
                    v[i]=0-v[i];
                for(i=1;i<=n;i++)
                    s[i]=s[i-1]+v[i];
                for(i=1;i<=4*N;i++)
                    aint[i]=INF;
                update(0,0);//minim=0;
                for(i=2;i<=n;i++)
                {
                    if(i-s[i]-s2[i]>query(-100000,s[i]-1))
                        ok=1;
                    update(s[i-1],i-1-s[i-1]-s2[i-1]);//minim=min(i-1-s[i-1],minim);
                }
                if(ok==1)
                    cout<<"yes";
                else
                    cout<<"no";
            }
        }
        cout<<'\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define task "codeforces"
#define rep(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define per(i,b,a) for(int i=(b),_a=(a);i>=_a;--i)
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define lla(v) (v).begin(),(v).end()
#define zs(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007; /// 998244353
const int base=311;
const int N=1e5+5;

int n,k,a[N];
pii f[N];
map<int,int> cnt;
void solved()
{
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>a[i];
    int ok=0;
    for(int i=1;i<=n;++i)
    {
        if(a[i]==k) {ok=1; break;}
    }
    if(!ok) {cout<<"no\n"; return;}
    if(ok&&n==1)
    {
        cout<<"yes\n";
        return;
    }
    for(int i=2;i<=n;++i)
    {
        if(a[i]==a[i-1]&&a[i]==k)
        {
            cout<<"yes\n";
            return;
        }
    }
    int ans=0;
    for(int i=1;i<=n;++i) f[i].fi=f[i-1].fi+(a[i]<=k?1:-1), f[i].se=i;
    sort(f,f+n+1);
    for(int i=-n;i<=n;++i) cnt[i]=1e9;
    for(int i=0;i<=n;++i)
    {
        cnt[f[i].fi]=min(cnt[f[i].fi],f[i].se);
        ans=max(ans,f[i].se-cnt[f[i].fi]);
    }
    for(int i=1;i<=n;++i) f[i].fi=f[i-1].fi+(a[i]>=k?1:-1), f[i].se=i;
    sort(f,f+n+1);
    for(int i=-n;i<=n;++i) cnt[i]=1e9;
    for(int i=0;i<=n;++i)
    {
        cnt[f[i].fi]=min(cnt[f[i].fi],f[i].se);
        ans=max(ans,f[i].se-cnt[f[i].fi]);
    }
    if(ans>=2)
    {
        cout<<"yes\n";
    }
    else cout<<"no\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    int t;
    cin>>t;
    while(t--) solved();
}


#include<bits/stdc++.h>
using namespace std;
#define task "codeforces"
#define rep(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define per(i,b,a) for(int i=(b),_a=(a);i>=_a;--i)
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define lla(v) (v).begin(),(v).end()
#define zs(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007; /// 998244353
const int base=311;
const int N=1e5+5;

int n,k,a[N];
pii f[N];
int cnt[N];
void solved()
{
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>a[i];
    int ok=0;
    for(int i=1;i<=n;++i)
    {
        if(a[i]==k) {ok=1; break;}
    }
    if(!ok) {cout<<"no\n"; return;}
    if(ok&&n==1)
    {
        cout<<"yes\n";
        return;
    }
    for(int i=2;i<=n;++i)
    {
        if(a[i]==a[i-1]&&a[i]==k)
        {
            cout<<"yes\n";
            return;
        }
    }
    for(int i=1;i<=n;++i) f[i].fi=f[i-1].fi+(a[i]<=k?1:-1), f[i].se=i;
    sort(f,f+n+1);
    for(int i=0;i<=n;++i) cnt[i]=1e9;
    int ans=0;
    for(int i=0;i<=n;++i)
    {
        cnt[f[i].fi]=min(cnt[f[i].fi],f[i].se);
        ans=max(ans,f[i].se-cnt[f[i].fi]);
    }
    if(ans>=2)
    {
        cout<<"yes\n";
    }
    else cout<<"no\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    int t;
    cin>>t;
    while(t--) solved();
}


#include<bits/stdc++.h>
using namespace std;
#define task ""
#define rep(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define per(i,b,a) for(int i=(b),_a=(a);i>=_a;--i)
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define ALL(v) (v).begin(),(v).end()
#define sz(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=1000000007; /// 998244353
const int base=311;
const int N=1e5+5;

int n,k,a[N];
void solved()
{
    cin>>n>>k;
    rep(i,1,n) cin>>a[i];
    a[n+1]=0, a[n+2]=0;
    if(n==1)
    {
        if(a[1]==k) cout<<"yes\n";
        else cout<<"no\n";
        return;
    }
    int ok=0;
    rep(i,1,n) ok|=(a[i]==k);
    if(!ok) {cout<<"no\n"; return;}
    ok=0;
    rep(i,1,n) ok|=(a[i]>=k&&(a[i+1]>=k||a[i+2]>=k));
    cout<<(ok?"yes":"no")<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    int t ;
    cin>>t;
    while(t--) solved();
}


#include<bits/stdc++.h>
using namespace std;
#define task ""
#define rep(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define per(i,b,a) for(int i=(b),_a=(a);i>=_a;--i)
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define ALL(v) (v).begin(),(v).end()
#define sz(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=1000000007; /// 998244353
const int base=311;
const int N=1e5+5;

int n,k,a[N];
void solved()
{
    cin>>n>>k;
    rep(i,1,n) cin>>a[i];
    if(n==1)
    {
        if(a[1]==k) cout<<"yes\n";
        else cout<<"no\n";
        return;
    }
    int ok=0;
    rep(i,1,n) ok|=(a[i]==k);
    if(!ok) {cout<<"no\n"; return;}
    ok=0;
    rep(i,1,n) ok|=(a[i]>=k&&(a[i+1]>=k||a[i+2]>=k));
    cout<<(ok?"yes":"no")<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    int t ;
    cin>>t;
    while(t--) solved();
}