using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
#if TextInput
			using(var reader = new StreamReader(Debug.SampleTextPath)) 
			{
				Console.SetIn(reader);
#endif
				var bingoNumbers = new List<int>();
				bingoNumbers.AddRange(IO.ReadIntArray());
				bingoNumbers.AddRange(IO.ReadIntArray());
				bingoNumbers.AddRange(IO.ReadIntArray());

				var checkNum = IO.ReadInt();
				for(var iIndex = 0 ; iIndex < checkNum ; ++ iIndex)
				{
					var checkNumber = IO.ReadInt();
					while(true)
					{
						var replaceIndex = bingoNumbers.IndexOf(checkNumber);
						if(replaceIndex == -1) { break; }
						bingoNumbers[replaceIndex] = -1;
					}
				}
				
				var isBingo = false;
				for(var iIndex = 0 ; iIndex < 3 ; ++ iIndex)
				{
					var horizontalIndex = iIndex * 3;
					if(bingoNumbers.Skip(horizontalIndex).Take(3).All(iNumber => iNumber == -1))
					{
						isBingo = true;
						break;
					}

					if(bingoNumbers[iIndex] == -1 &&
					   bingoNumbers[iIndex + 3] == -1 &&
					   bingoNumbers[iIndex + 6] == -1)
					{
						isBingo = true;
						break;
					}
				}
				if(!isBingo)
				{
					if(bingoNumbers[4] == -1)
					{
						isBingo = (bingoNumbers[0] == -1 && bingoNumbers[8] == -1) ||
								  (bingoNumbers[2] == -1 && bingoNumbers[6] == -1);
					}
				}

				IO.Write(isBingo);
#if TextInput
			}
#endif
		}
	}

	public static class IO
	{
		public static string   Read()								 { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')		 { return Read().Split(iSplitter); }
		public static int	   ReadInt()							 { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()							 { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static double   ReadDouble()							 { return double.Parse(Read()); }
		public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()						 { return Read().ToCharArray(); }

		public static void Write(string iValue)									   { Console.WriteLine(iValue); }
		public static void Write(int iValue)									   { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue , string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord , iValue)); }
		public static void Write(long iValue)									   { Console.WriteLine(iValue); }
		public static void Write(double iValue)									   { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)								   { Console.WriteLine(iValue); }
		public static void Write(bool iValue)									   { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}
		public static long CombinationNum(int iLeftNumber , int iRightNumber)
		{
			if(iRightNumber == 0) { return 1; }
			if(iLeftNumber == 0)  { return 0; }
			return iLeftNumber * CombinationNum(iLeftNumber - 1 , iRightNumber - 1) / iRightNumber;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


Measured memory_bytes: 13396