/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%llu\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	
	data->getInput();
	const int a1 = data->getNum()[0], a2 = data->getNum()[1], a3 = data->getNum()[2];
	data->getInput();
	const int b1 = data->getNum()[0], b2 = data->getNum()[1], b3 = data->getNum()[2];
	data->getInput();
	const int c1 = data->getNum()[0], c2 = data->getNum()[1], c3 = data->getNum()[2];

	bool a1f = false, a2f = false, a3f = false;
	bool b1f = false, b2f = false, b3f = false;
	bool c1f = false, c2f = false, c3f = false;

	data->getInput();
	const int max = data->getNum()[0];

	for (int i = 0; i < max; i++) {
		data->getInput();
		const int ansbuf = data->getNum()[0];

		if (ansbuf == a1) {
			a1f = true;
		}
		if (ansbuf == a2) {
			a2f = true;
		}
		if (ansbuf == a3) {
			a3f = true;
		}
		if (ansbuf == b1) {
			b1f = true;
		}
		if (ansbuf == b2) {
			b2f = true;
		}
		if (ansbuf == b3) {
			b3f = true;
		}
		if (ansbuf == c1) {
			c1f = true;
		}
		if (ansbuf == c2) {
			c2f = true;
		}
		if (ansbuf == c3) {
			c3f = true;
		}
	}

	bool ansc1 = a1f && b1f && c1f;
	bool ansc2 = a2f && b2f && c2f;
	bool ansc3 = a3f && b3f && c3f;
	bool ansr1 = a1f && a2f && a3f;
	bool ansr2 = b1f && b2f && b3f;
	bool ansr3 = c1f && c2f && c3f;
	bool ansx1 = a1f && b2f && c3f;
	bool ansx2 = a3f && b2f && c1f;

	bool ans = false;
	if (ansc1 || ansc2 || ansc3 || ansr1 || ansr2 || ansr3 || ansx1 || ansx2) {
		ans = true;
	}

	if (ans) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	delete(data);

	return 0;
}


Measured memory_bytes: 256