/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class bbg
{
	public static int result;

public static ArrayList<Integer> [] graph;

public static int[]cats;

public static int vizitat[];
public static int x;

	public static void main (String[] args) throws java.lang.Exception
{

Scanner input=new Scanner(System.in);

HashMap<String, Integer> map1= new HashMap<String, Integer>();
HashMap<Integer, Integer> map2= new HashMap<Integer, Integer>();

	int [][] m=new int[5][5];

	for(int i=1;i<5;i++)
	for(int j=1;j<5;j++)

	m[i][j]=input.nextInt();

 int x=0;

 if(m[1][4]==1 && (m[1][2]==1 ||m[1][1]==1 ||m[1][3]==1 || m[2][1]==1 || m[3][2]==1 || m[4][3]==1 )) x=1;

 if(m[2][4]==1 && (m[2][2]==1 ||m[2][1]==1 ||m[2][3]==1 || m[3][1]==1 || m[4][2]==1 || m[1][3]==1 )) x=1;

 if(m[3][4]==1 && (m[3][2]==1 ||m[3][1]==1 ||m[3][3]==1 || m[4][1]==1 || m[1][2]==1 || m[2][3]==1 )) x=1;

  if(m[4][4]==1 && (m[4][2]==1 ||m[4][1]==1 ||m[4][3]==1 || m[1][1]==1 || m[2][2]==1 || m[3][3]==1 )) x=1;

  if(x==0) System.out.println("NO");
  else System.out.println("YES");

}

			}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A_ {
	public static void main(String[]args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		int [] l= new int[4];
		int [] s= new int[4];
		int [] r= new int[4];
		int [] p= new int[4];
		boolean flag= false;
		for(int i=0; i< 4; i++){
			l[i]= scanner.nextInt();
			s[i]= scanner.nextInt();
			r[i]= scanner.nextInt();
			p[i]= scanner.nextInt();
		}
		if(p[0]==1){
			if(l[0]==1 || s[0] ==1 || r[0] ==1 || l[1]==1 || s[2]==1 || r[3]==1 ){
				System.out.println("YES");
				flag= true;
			}

		}
		if(p[1]==1 && !flag){
			if(l[1]==1 || s[1] ==1 || r[1] ==1 || l[2]==1 || s[3]==1 || r[0]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		if(p[2]==1 && !flag){
			if(l[2]==1 || s[2] ==1 || r[2] ==1 || l[3]==1 || s[0]==1 || r[1]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		if(p[3]==1 && !flag){
			if(l[3]==1 || s[3] ==1 || r[3] ==1 || l[0]==1 || s[1]==1 || r[2]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		if(!flag)
			System.out.println("NO");

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

	}

}

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

public class Crossroads {
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

	public static void main(String args[]) throws Exception {

		class prob {
			public void solve() {
				MyScanner s = new MyScanner();
				int [][]in = new int[4][4];
				for (int i = 0; i < 4; ++i) {
					for (int j = 0; j < 4; ++j) {
						in[i][j] = s.nextInt();
					}
				}

				for (int i = 0; i < 4; ++i) {
					if ((in[i][0] == 1 || in[i][1] == 1 || in[i][2] == 1) && in[i][3] == 1) {
						System.out.print("YES");
						return;
					}
					int oIndx = (i + 2) % 4;
					if (in[i][1] == 1 && in[oIndx][3] == 1) {
						System.out.print("YES");
						return;
					}
					if (in[i][0] == 1) {
						// i + 3 % 4 || 3 - i % 4
						int idx = (i + 3) % 4;
						if (idx != i) {
							if (in[idx][3] == 1) {
								System.out.print("YES");
								return;
							}
						}
					}
					if (in[i][2] == 1) {
						int idx = (i + 1) % 4;
						if (idx != i) {
							if (in[idx][3] == 1) {
								System.out.print("YES");
								return;
							}
						}
					}
				}
				System.out.print("NO");
			}

		}
		prob s = new prob();
		s.solve();
	}
}

import java.io.*;
import java.util.*;

public class Main {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int[][] arr = new int[4][4];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				arr[i][j] = scn.nextInt();
			}
		}
		for(int i = 0; i < 4; i++) {
			if(arr[i][3] == 1) {
				for(int j = 0; j < 3; j++) {
					if(arr[i][j] == 1) {
						out.println("YES");
						return;
					}
				}
			}
		}
		if ((arr[0][0] == 1 && arr[3][3] == 1) || (arr[0][1] == 1 && (arr[0][3] == 1 || arr[2][3] == 1))
				|| (arr[0][2] == 1 && arr[1][3] == 1)) {
			out.println("YES");
		} else if ((arr[1][0] == 1 && arr[0][3] == 1) || (arr[1][1] == 1 && (arr[1][3] == 1 || arr[3][3] == 1))
				|| (arr[1][2] == 1 && arr[2][3] == 1)) {
			out.println("YES");
		} else if ((arr[2][0] == 1 && arr[1][3] == 1) || (arr[2][1] == 1 && (arr[2][3] == 1 || arr[0][3] == 1))
				|| (arr[2][2] == 1 && arr[3][3] == 1)) {
			out.println("YES");
		} else if ((arr[3][0] == 1 && arr[2][3] == 1) || (arr[3][1] == 1 && (arr[3][3] == 1 || arr[1][3] == 1))
				|| (arr[3][2] == 1 && arr[0][3] == 1)) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	void run() throws Exception {
		boolean onlineJudge = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(onlineJudge);
		long time = System.currentTimeMillis();
		solve();
		out.flush();
		if (!onlineJudge) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

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

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

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

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n, boolean isOneInd) {
			int k = isOneInd ? 1 : 0;
			int[] a = new int[n + k];
			for (int i = k; i < n + k; i++)
				a[i] = nextInt();
			return a;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}

import java.util.Scanner;
public class Ahmed {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
       int arr[][];
       boolean flag=false;
       arr=new int[4][4];
       for(int i=0;i<4;++i)
       {
           for(int j=0;j<4;++j)
               arr[i][j]=input.nextInt();
       }
       if(arr[0][3]==1&&(arr[1][0]+arr[3][2]+arr[2][1]>0))
           System.out.println("YES");
       else if(arr[1][3]==1&&(arr[2][0]+arr[0][2]+arr[3][1]>0))
           System.out.println("YES");
       else if(arr[2][3]==1&&(arr[1][2]+arr[3][0]+arr[0][1]>0))
           System.out.println("YES");
       else if(arr[3][3]==1&&(arr[0][0]+arr[2][2]+arr[1][1]>0))
           System.out.println("YES");
       else
       {
           for(int i=0;i<4;++i)
               if(arr[i][3]==1&&arr[i][0]+arr[i][1]+arr[i][2]>0)
               {
                   flag=true;
                   break;
               }
           System.out.println(flag?"YES":"NO");
       }
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.lang.StringBuilder;
import java.lang.StringBuffer;
import java.math.BigInteger;
import java.text.DecimalFormat;
@SuppressWarnings("unused")

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		int[][] road = new int[4][4];

		for (int i = 0 ; i < 4 ; i++){
			StringTokenizer st = new StringTokenizer(bf.readLine());
			for (int j = 0 ; j < 4 ; j++){
				road[i][j] = Integer.parseInt(st.nextToken());
			}
		}

		for (int i = 0 ; i < 4 ; i++){
			for (int j = 0 ; j < 3 ; j++){
				if (road[i][j] == 1){
					if (road[i][3] == 1){
						System.out.println("YES");return;
					}
					if(j == 0){
						if (i == 0 && road[3][3] == 1){
							System.out.println("YES");return;
						}
						else if (i > 0){
							if (road[i-1][3] == 1){
								System.out.println("YES");return;
							}
						}
					}
					if (j == 1){
						if (i == 0 && road[2][3] == 1){
							System.out.println("YES");return;
						}
						else if (i == 1 && road[3][3] == 1){
							System.out.println("YES");return;
						}
						else if (i > 1 && road[((i+1)/2)-1][3] == 1){
							System.out.println("YES");return;
						}
					}
					if (j == 2){
						if (i == 3 && road[0][3] == 1){
							System.out.println("YES");return;
						}
						else if (i < 3){
							if (road[i+1][3] == 1){
								System.out.println("YES");return;
							}
						}
					}
				}
			}
		}
		System.out.println("NO");
	}
}

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

public class A812{
	public static void main(String[] args){
		Scanner scan= new Scanner(System.in);
		int[] l= new int[4];
		int[] r= new int[4];
		int[] s= new int[4];
		int[] p= new int[4];
		int i=0,flag=0;
		for(i=0;i<4;i++){
			l[i]=scan.nextInt();
			s[i]=scan.nextInt();
			r[i]=scan.nextInt();
			p[i]=scan.nextInt();
			if(p[i]==1){
				flag=1;
			}
		}

		if(flag==1){
			for(i=0;i<4;i++){
				if(p[i]==1){
					if(l[(i+1)%4]==1){
						System.out.println("YES");
						System.exit(0);
					}
					if(s[(i+2)%4]==1){
						System.out.println("YES");
						System.exit(0);
					}
					if(r[(i+3)%4]==1){
						System.out.println("YES");
						System.exit(0);
					}
					if(l[i]==1||r[i]==1||s[i]==1){
						System.out.println("YES");
						System.exit(0);
					}
					else{
						flag=0;
					}
				}
			}
		}
		if(flag==0){
			System.out.println("NO");
		}
	}
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        boolean[] vals = new boolean[32];
        int idx = 0;
        Set<Integer> peds = new HashSet<>();
        for(int i = 0; i<4; i++){
            st = new StringTokenizer(br.readLine());
            while(st.hasMoreTokens()) {
                vals[idx++] = (st.nextToken().equals("0") ? false : true);
                if(!st.hasMoreTokens() && vals[idx-1]){
                    peds.add(i);
                }
            }
        }

        for(int i = 0; i<4; i++){
            if( (vals[i*4] || vals[i*4 + 1] || vals[i*4 + 2]) && vals[i*4 + 3]){
                System.out.println("YES");
                return;
            }

            if(vals[i*4] && peds.contains(i-1 >= 0 ? i-1 : 3)){
                System.out.println("YES");
                return;
            }

            if(vals[i*4 + 1] && peds.contains((i+2) % 4)){
                System.out.println("YES");
                return;
            }

            if(vals[i*4 + 2] && peds.contains((i+1) % 4)){
                System.out.println("YES");
                return;
            }
        }

        System.out.println("NO");
        return;

    }
}

    import java.util.*;
    import java.lang.Math;
    import java.util.Arrays;
    import java.util.Scanner;
    import java.util.stream.IntStream;
    import java.io.OutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;

    public class Problem {
       	public static void main(String[] args) {
    	   InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            Scanner in = new Scanner(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            TaskA solver = new TaskA();
            solver.solve(1, in, out);
            out.close();
    	}

    	static class TaskA {
          public void solve(int testNumber, Scanner in, PrintWriter out) {
                  int a[][] = new int[4][4];
                  for(int i=0;i<4;i++){
                       for(int j=0;j<4;j++){
                            a[i][j] = in.nextInt();
                       }
                  }
                  int l =0,s=0,r=0;
                  for(int i=0;i<4;i++){
                       if(a[i][3]==1){
                            if(i==0){
                                 if(a[i][0]==1||a[i][1]==1||a[i][2]==1||a[1][0]==1||a[2][1]==1||a[3][2]==1){
                                      out.print("YES");
                                      return;
                                 }
                            }
                            else if(i==1){
                                 if(a[i][0]==1||a[i][1]==1||a[i][2]==1||a[2][0]==1||a[3][1]==1||a[0][2]==1){
                                      out.print("YES");
                                      return;
                                 }
                            }
                            else if(i==2){
                                 if(a[i][0]==1||a[i][1]==1||a[i][2]==1||a[3][0]==1||a[0][1]==1||a[1][2]==1){
                                      out.print("YES");
                                      return;
                                 }
                            }
                            else if(i==3){
                                 if(a[i][0]==1||a[i][1]==1||a[i][2]==1||a[0][0]==1||a[1][1]==1||a[2][2]==1){
                                      out.print("YES");
                                      return;
                                 }
                            }
                       }
                       else{
                            continue;
                       }
                  }
                out.println("NO");
          }
    	}

    public int factorial(int n) {
            int fact = 1;
            int i = 1;
           while(i <= n) {
             fact *= i;
             i++;
           }
            return fact;
    }

    public static int BinarySearch(long temp,long[] sum,int r)
    {
    	int l=0;

    	while(l<=r)
    	{
    		int mid=l+(r-l)/2;
    		if(sum[mid]==temp&&sum[mid]!=-1)
    		{
    		return mid;
    		}
    		if(sum[mid]>temp&&sum[mid]!=-1)
    			r=mid-1;
    		if(sum[mid]<temp&&sum[mid]!=-1)
    			l=mid+1;
        }
    	return -1;
    }
    public static long gcd(long x,long y)
    {
    	if(x%y==0)
    		return y;
    	else
    		return gcd(y,x%y);
    }
    public static int gcd(int x,int y)
    {
    	if(x%y==0)
    		return y;
    	else
    		return gcd(y,x%y);
    }
    public static int abs(int a,int b)
    {
    	return (int)Math.abs(a-b);
    }
    public static long abs(long a,long b)
    {
    	return (long)Math.abs(a-b);
    }
    public static int max(int a,int b)
    {
    	if(a>b)
    		return a;
    	else
    		return b;
    }
    public static int min(int a,int b)
    {
    	if(a>b)
    		return b;
    	else
    		return a;
    }
    public static long max(long a,long b)
    {
    	if(a>b)
    		return a;
    	else
    		return b;
    }
    public static long min(long a,long b)
    {
    	if(a>b)
    		return b;
    	else
    		return a;
    }

    public static long pow(long n,long p,long m)
    {
    	 long  result = 1;
    	  if(p==0)
    	    return 1;
    	if (p==1)
    	    return n;
    	while(p!=0)
    	{
    	    if(p%2==1)
    	        result *= n;
    	    if(result>=m)
    	    result%=m;
    	    p >>=1;
    	    n*=n;
    	    if(n>=m)
    	    n%=m;
    	}
    	return result;
    }
    public static long pow(long n,long p)
    {
    	long  result = 1;
    	  if(p==0)
    	    return 1;
    	if (p==1)
    	    return n;
    	while(p!=0)
    	{
    	    if(p%2==1)
    	        result *= n;
    	    p >>=1;
    	    n*=n;
    	}
    	return result;

    }

    static long sort(int a[]){
         int n=a.length;
    	int b[]=new int[n];
    	return mergeSort(a,b,0,n-1);

    }

    static long mergeSort(int a[],int b[],long left,long right){
         long c=0;
         if(left<right){
          long mid=left+(right-left)/2;
    	 c= mergeSort(a,b,left,mid);
    	 c+=mergeSort(a,b,mid+1,right);
    	 c+=merge(a,b,left,mid+1,right);
         }
    	return c;
    }
    static long merge(int a[],int  b[],long left,long mid,long right){
         long c=0;int i=(int)left;int j=(int)mid; int k=(int)left;
         while(i<=(int)mid-1&&j<=(int)right){
              if(a[i]<=a[j]){
                   b[k++]=a[i++];
              }
              else{
                   b[k++]=a[j++];c+=mid-i;
              }
         }

         while (i <= (int)mid - 1)
                 b[k++] = a[i++];
         while (j <= (int)right)
                 b[k++] = a[j++];
         for (i=(int)left; i <= (int)right; i++)
    	        a[i] = b[i];
    	        return c;
         }

    }

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Amine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        crossroads solver = new crossroads();
        solver.solve(1, in, out);
        out.close();
    }

    static class crossroads {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[][] map = new int[4][4];
            for (int i = 0; i < 4; ++i) {
                for (int j = 0; j < 4; ++j) {
                    map[i][j] = in.nextInt();
                }
            }
            // l s r p
            int temp = -1;
            int ok1 = (map[1][3] == 1) ? (map[0][2] + map[1][3] + map[3][1] + map[2][0] + map[1][0] + map[1][1] + map[1][2]) : 0;
            int ok2 = (map[2][3] == 1) ? (map[2][3] + map[1][2] + map[0][1] + map[3][0] + map[2][0] + map[2][1] + map[2][2]) : 0;
            int ok3 = (map[3][3] == 1) ? (map[3][3] + map[2][2] + map[1][1] + map[0][0] + map[3][0] + map[3][1] + map[3][2]) : 0;
            int ok4 = (map[0][3] == 1) ? (map[0][3] + map[3][2] + map[2][1] + map[1][0] + map[0][0] + map[0][1] + map[0][2]) : 0;
            if (ok1 > 1 || ok2 > 1 || ok3 > 1 || ok4 > 1)
                out.println("YES");
            else
                out.println("NO");
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A417 {
	public static void main(String args[]) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		int l[] = new int[4];
		int s[] = new int[4];
		int r[] = new int[4];
		int p[] = new int[4];
		for (int i=0;i<4;i++)
		{
			l[i] = sc.nextInt();
			s[i] = sc.nextInt();
			r[i] = sc.nextInt();
			p[i] = sc.nextInt();
			if ((l[i]==1 || r[i]==1|| s[i]==1) && p[i]==1)
			{
				System.out.println("YES");
				return;
			}
		}
		if (p[0]==1)
		{
			if (l[1]==1 || s[2]==1 || r[3]==1)
			{
				System.out.println("YES");
				return;
			}
		}
		if (p[1]==1)
		{
			if (l[2]==1 || s[3]==1 || r[0]==1)
			{
				System.out.println("YES");
				return;
			}
		}
		if (p[2]==1)
		{
			if (l[3]==1 || s[0]==1 || r[1]==1)
			{
				System.out.println("YES");
				return;
			}
		}
		if (p[3]==1)
		{
			if (l[0]==1 || s[1]==1 || r[2]==1)
			{
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

	}
}

import java.util.Scanner;

public class A812 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int[][] a= new int[4][4];
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++)
				a[i][j]=s.nextInt();
		}
		boolean acc=false;
		for(int i=0;i<4;i++){
			if(a[i][3]!=1)
				continue;
			else{
				if(a[i][0]==1 ||a[i][1]==1 ||a[i][2]==1 || a[(i+1) %4][0]==1 ||a[(i+2) %4][1]==1 || a[(i+3) %4][2]==1){
					acc=true;
					break;
				}
			}

		}
		if(acc)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String result = "NO";
        Scanner sc = new Scanner(System.in);
        boolean[][] arr = new boolean[4][4];
        for (int i = 0; i < 4; i++) {
            String[] s = sc.nextLine().split(" ");

            for (int j = 0; j < s.length; j++) {
                if (s[j].equals("0")) {
                    arr[i][j] = false;
                } else {

                    arr[i][j] = true;
                }
            }

        }

        for (int i = 0; i < 4; i++) {
            if (arr[i][3] == true) {
                if (arr[i][0] == true || arr[i][1] == true || arr[i][2] == true) {
                    result = "YES";
                    break;
                }
            }
            int tmp;
            if (i == 2) tmp = 0;
            else if (i == 3) tmp = 1;
            else tmp = i + 2;
            if (arr[i][1] == true && arr[tmp][3] == true) {
                result = "YES";
                break;
            }

            if (i == 0) tmp = 3;
            else tmp = i - 1;
            if (arr[i][0] == true && arr[tmp][3] == true) {
                result = "YES";
                break;
            }

            if (i == 3) tmp = 0;
            else tmp = i + 1;
            if (arr[i][2] == true && arr[tmp][3] == true) {
                result = "YES";
                break;
            }
        }

        System.out.println(result);

    }
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] road = new int[16];
        for (int i = 0; i < 16; i++) {
            road[i] = scanner.nextInt();
        }
        if (road[3] == 1
                && (road[0] == 1 || road[1] == 1 || road[9] == 1 || road[2]==1
                || road[4] == 1 || road[14] == 1)) {
            System.out.println("YES");
        } else {
            if (road[7] == 1
                    && (road[4] == 1 || road[5] == 1 || road[6] == 1 || road[13]==1
                    || road[2] == 1 || road[8] == 1)) {
                System.out.println("YES");
            }else{
                if (road[11] == 1
                        && (road[8] == 1 || road[9] == 1 || road[10] == 1 || road[1]==1
                        || road[12] == 1 || road[6] == 1)) {
                    System.out.println("YES");
                }else{
                    if (road[15] == 1
                            && (road[12] == 1 || road[13] == 1 || road[14] == 1 || road[5]==1
                            || road[0] == 1 || road[10] == 1)) {
                        System.out.println("YES");
                    }else{
                        System.out.println("NO");
                    }
                }
            }
        }
    }
}

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

public class utkarsh {

    InputStream is;
    PrintWriter out;

    long maxl = 1234567890987654321L, mod = 1000000007L;
    int p[], maxi = 1234567890, sz, np = 20000000;
    boolean b[];    // = isPrime();

    void solve(){
        //Enter code here utkarsh
        //sz=sieve(); //sz=1270607;
        //out.println(sz);
        int i, j;
        int a[][] = new int[4][4];
        for(i = 0; i < 4; i++){
            for(j = 0; j < 4; j++){
                a[i][j] = ni();
            }
        }
        for(i = 0; i < 4; i++){
            if(a[i][3] == 1){
            for(j = 0; j < 3; j++){
                if(a[i][j] == 1){
                    out.println("YES");
                    return;
                }
            }
            if(a[(i+1)%4][0] == 1){
                out.println("YES");
                return;
            }
            if(a[(i+3)%4][2] == 1){
                out.println("YES");
                    return;
            }
            if(a[(i+2)%4][1] == 1){
                out.println("YES");
                    return;
            }
            }
        }
        out.println("NO");
    }

    int sieve(){ int i, j, n = np; b = new boolean[n]; for(i = 3; i < n; i += 2){ b[i] = true; } b[2] = true; for(i = 3; i * i <= n; i += 2){ if(b[i]){ for(j = 2 * i; j < n; j += i){ b[j] = false; } } } p = new int[n]; p[0] = 2; j = 1; for(i = 3; i < n; i += 2){ if(b[i]){ p[j++] = i; } } p=Arrays.copyOf(p,j); return j;
    }
    long modpow(long base, long exp, long modulus) { base %= modulus; long result = 1L; while (exp > 0) { if ((exp & 1)==1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return result;
    }

    public static void main(String[] args) { new utkarsh().run();
    }
    void run(){ is = System.in; out = new PrintWriter(System.out); solve(); out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte(){ if(ptr >= len){ ptr = 0; try{ len = is.read(input); }catch(IOException e){ throw new InputMismatchException(); } if(len <= 0){ return -1; } } return input[ptr++];
    }
    boolean isSpaceChar(int c){ return !( c >= 33 && c <= 126 );
    }
    int skip(){ int b = readByte(); while(b != -1 && isSpaceChar(b)){ b = readByte(); } return b;
    }

    char nc(){ return (char)skip();
    }
    String ns(){ int b = skip(); StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString();
    }
    int ni(){ int n = 0,b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } if(b == -1){ return -1; } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    long nl(){ long n = 0L; int b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    double nd(){ return Double.parseDouble(ns());
    }
    float nf(){ return Float.parseFloat(ns());
    }
    int[] na(int n){ int a[] = new int[n]; for(int i = 0; i < n; i++){ a[i] = ni(); } return a;
    }
    char[] ns(int n){ char c[] = new char[n]; int i,b = skip(); for(i = 0; i < n; i++){ if(isSpaceChar(b)){ break; } c[i] = (char)b; b = readByte(); } return i == n ? c : Arrays.copyOf(c,i);
    }
}

import java.util.Scanner;
public class TrafficLight {
    public static void main(String[] args) {
        int[][] intersection  = new int[4][4];
        Scanner kb = new Scanner(System.in);
        StringBuilder input = new StringBuilder();
        for(int i = 0; i < 4; i++){
            input.append(kb.nextLine());
            input.append(" ");
        }
        String[] inputs = input.toString().split(" ");
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 4; j++){
                intersection[i][j] = Integer.parseInt(inputs[(i*4) + j]);
            }
        }

        boolean nocrash =  true;

        for(int i = 0; i < 4; i++){
            if(intersection[i][3] == 1){
                if(intersection[i][1] == 1 ||intersection[i][0] == 1 ||intersection[i][2] == 1 || intersection[(i + 1) % 4][0] == 1 || intersection[(i+2) % 4][1] == 1 || intersection[(i+3) % 4][2] == 1){
                    nocrash = false;
                }
            }
        }
        if(nocrash){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author niquefa_diego
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            final int n = 4;
            boolean l[] = new boolean[n];
            boolean s[] = new boolean[n];
            boolean r[] = new boolean[n];
            boolean p[] = new boolean[n];
            for (int i = 0; i < n; ++i) {
                l[i] = 1 == in.nextInt();
                s[i] = 1 == in.nextInt();
                r[i] = 1 == in.nextInt();
                p[i] = 1 == in.nextInt();
            }

            boolean ans = false;
            for (int i = 0; i < n; ++i) {
                if (l[i] && p[(i + n - 1) % n]) ans = true;
                if (r[i] && p[(i + 1) % n]) ans = true;
                if (s[i] && p[(i + 2) % n]) ans = true;
                if (p[i] && (l[i] || r[i] || s[i])) ans = true;
            }

            out.println(ans ? "YES" : "NO");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer = null;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

import java.io.*;
import java.util.*;

/*
TASK: CFA
LANG: JAVA
 */
public class CFA {
    static int[] l , s , r , p;

    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        l = new int[4];
        s = new int[4];
        r = new int[4];
        p = new int[4];
        for(int i = 0;i < 4; i++){
            l[i] = in.nextInt();
            s[i] = in.nextInt();
            r[i] = in.nextInt();
            p[i] = in.nextInt();
        }
        for(int i = 0;i < 4; i++){
            if(p[i]== 1){
                if(l[i] == 1 || s[i] == 1 || r[i] == 1 || l[(i+1)%4] == 1 || r[(i+3)%4] == 1 || s[(i+2)%4] == 1){
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    private static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        boolean isEndline(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

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

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class pola {

	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st = new StringTokenizer(br.readLine());
	//	int n = Integer.parseInt(st.nextToken());
		int [][]Arr=new int [4][4];
		for(int i=0;i<4;i++){
			StringTokenizer st = new StringTokenizer(br.readLine());
		for(int j=0;j<4;j++)
			Arr[i][j]= Integer.parseInt(st.nextToken());
		}
		if(Arr[0][3]==1){
			if(Arr[0][0]==1||Arr[0][1]==1||Arr[0][2]==1||Arr[2][1]==1||Arr[3][2]==1||Arr[1][0]==1){
				System.out.println("YES");return;
			}

		}
		if(Arr[1][3]==1){
			if(Arr[1][0]==1||Arr[1][1]==1||Arr[1][2]==1||Arr[3][1]==1||Arr[0][2]==1||Arr[2][0]==1){
				System.out.println("YES");return;
			}

		}
		if(Arr[2][3]==1){
			if(Arr[2][0]==1||Arr[2][1]==1||Arr[2][2]==1||Arr[0][1]==1||Arr[1][2]==1||Arr[3][0]==1){
				System.out.println("YES");return;
			}

		}
		if(Arr[3][3]==1){
			if(Arr[3][0]==1||Arr[3][1]==1||Arr[3][2]==1||Arr[1][1]==1||Arr[2][2]==1||Arr[0][0]==1){
				System.out.println("YES");return;
			}

		}
		System.out.println("NO");

	}

}

import java.util.Scanner;

public class JavaApplication22 {

    public static void main(String[] args) {
       Scanner in=new Scanner(System.in);
       int count=0;
        int arr[][]=new int[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                arr[i][j]=in.nextInt();
            }
        }
        if (arr[0][3]==1) {
            if (arr[0][0]==1||arr[0][1]==1||arr[0][2]==1) {
                System.out.println("YES");
                return;
            }
            if (arr[1][0]==1||arr[2][1]==1||arr[3][2]==1) {
                System.out.println("YES");
                return;
            }
        }
        if (arr[1][3]==1) {
            if (arr[1][0]==1||arr[1][1]==1||arr[1][2]==1) {
                System.out.println("YES");
                return;
            }
            if (arr[0][2]==1||arr[2][0]==1||arr[3][1]==1) {
                System.out.println("YES");
                return;
            }
        }
        if (arr[2][3]==1) {
            if (arr[2][0]==1||arr[2][1]==1||arr[2][2]==1) {
                System.out.println("YES");
                return;
            }
            if (arr[1][2]==1||arr[0][1]==1||arr[3][0]==1) {
                System.out.println("YES");
                return;
            }
        }
        if (arr[3][3]==1) {
            if (arr[3][0]==1||arr[3][1]==1||arr[3][2]==1) {
                System.out.println("YES");
                return;
            }
            if (arr[1][1]==1||arr[2][2]==1||arr[0][0]==1) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
        }
     }

/**
 * Created by Ariana Herbst on 6/13/17.
 */

import java.util.*;
import java.io.*;

public class cfs417A {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        StringBuilder sb = new StringBuilder();
        boolean[] lights = new boolean[12];
        boolean[] ped = new boolean[4];
        boolean ans = false;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                lights[i*3 + j] = (sc.nextInt() == 1);
            }
            ped[i] = (sc.nextInt() == 1);
        }
        for (int i = 0; i < 12; i += 3) {
            if (ped[i/3]) {
                for (int j = i-1; j <= i + 3; j++) {
                    if (lights[(j+12)%12]) {
                        ans = true;
                    }
                }
                if (lights[(7+i)%12]) {
                    ans = true;
                }
            }
        }
        sb.append(ans ? "YES" : "NO");
        System.out.println(sb);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }

        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextLong();
            }
            return a;
        }
    }
}

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

public class Promotions {
	public static void main(String[]args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int[][]a = new int[4][4];
		boolean flag = false;
		for(int i = 0 ; i < 4 ; i ++){
			StringTokenizer tkn = new StringTokenizer(r.readLine());
			int x = 0;
			for(int j = 0 ; j < 4 ; j++){
				a[i][j]=Integer.parseInt(tkn.nextToken());
				if(j!=3) x = x|a[i][j];
			}
			x = x&a[i][3];
			if(x>0)flag = true;
		}

		if(a[0][3]==1){
			if((a[1][0]|a[2][1]|a[3][2]|a[0][1])>0) flag = true;
		}
		if(a[1][3]==1){
			if((a[0][2]|a[2][0]|a[3][1]|a[1][1])>0) flag = true;
		}
		if(a[2][3]==1){
			if((a[0][1]|a[1][2]|a[3][0]|a[2][1])>0) flag = true;
		}
		if(a[3][3]==1){
			if((a[0][0]|a[1][1]|a[2][2]|a[3][1])>0) flag = true;
		}
		System.out.println(flag?"YES":"NO");

	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HussienMoustafa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FSagheerAndCrossroads solver = new FSagheerAndCrossroads();
        solver.solve(1, in, out);
        out.close();
    }

    static class FSagheerAndCrossroads {
        public void solve(int testNumber, Scanner s, PrintWriter out) {
            int l1, l2, l3, l4, r1, r2, r3, r4, s1, s2, s3, s4, p1, p2, p3, p4;

            l1 = s.nextInt();
            s1 = s.nextInt();
            r1 = s.nextInt();
            p1 = s.nextInt();

            l2 = s.nextInt();
            s2 = s.nextInt();
            r2 = s.nextInt();
            p2 = s.nextInt();

            l3 = s.nextInt();
            s3 = s.nextInt();
            r3 = s.nextInt();
            p3 = s.nextInt();

            l4 = s.nextInt();
            s4 = s.nextInt();
            r4 = s.nextInt();
            p4 = s.nextInt();

            if (p1 == 1 && (r1 == 1 || l1 == 1 || l2 == 1 || r4 == 1 || s3 == 1 || s1 == 1)) {
                out.println("YES");
            } else if (p2 == 1 && (r2 == 1 || l2 == 1 || l3 == 1 || r1 == 1 || s4 == 1 || s2 == 1)) {
                out.println("YES");
            } else if (p3 == 1 && (r3 == 1 || l3 == 1 || l4 == 1 || r2 == 1 || s1 == 1 || s3 == 1)) {
                out.println("YES");
            } else if (p4 == 1 && (r4 == 1 || l4 == 1 || l1 == 1 || r3 == 1 || s2 == 1 || s4 == 1)) {
                out.println("YES");
            } else out.println("NO");
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}

import java.io.*;
import java.util.*;

public class ProblemA {

    public static void main(String[] args) throws IOException {
        init();
        new ProblemA().run();
        out.flush();
        out.close();
    }

    static void init() throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in.ordinaryChars(0, 65535);
        in.wordChars(0, 65535);
        in.whitespaceChars(' ', ' ');
        in.whitespaceChars('\n', '\n');
        in.whitespaceChars('\r', '\r');
    }

    // класс для пар
    class Pair<L, R> {
        private final L X;
        private final R Y;

        public Pair(L X, R Y) {
            this.X = X;
            this.Y = Y;
        }

        public L getX() {
            return X;
        }

        public R getY() {
            return Y;
        }

        @Override
        public int hashCode() {
            return X.hashCode() ^ Y.hashCode();
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Pair)) return false;
            Pair pairo = (Pair) o;
            return X.equals(pairo.getX()) && Y.equals(pairo.getY());
        }
    }

    static final long INFL = 200000000000000000L;
    static final int INF = 2000000000;
    static final boolean DEBUG = true;

    static StreamTokenizer in;
    static PrintWriter out;

    static void print(String s) {
        print(s, 0);
    }

    static void print(String s, int debug) {
        if (debug == 0 || DEBUG) {
            out.print(s);
        }
    }

    static void println(String s) {
        println(s, 0);
    }

    static void println(String s, int debug) {
        if (debug == 0 || DEBUG) {
            out.println(s);
        }
    }

    static void printArray(int[] arr) {
        println(Arrays.toString(arr));
    }

    static void printArray(char[] arr) {
        println(Arrays.toString(arr));
    }

    static void printArray(String[] arr) {
        println(Arrays.toString(arr));
    }

    static void sort(int[] a) {
        Random rnd = new Random();
        for (int i = a.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i);
            a[i] ^= a[index];
            a[index] ^= a[i];
            a[i] ^= a[index];
        }
        Arrays.sort(a);
    }

    static char[] inChars;
    static int inCharsInd;

    static String next() throws IOException {
        in.nextToken();
        return in.sval;
    }

    static char nextChar() throws IOException {
        while (inChars == null || inCharsInd >= inChars.length) {
            inChars = next().toCharArray();
            inCharsInd = 0;
        }
        return inChars[inCharsInd++];
    }

    static int nextInt() throws IOException {
        return Integer.valueOf(next());
    }

    static double nextDouble() throws IOException {
        return Double.valueOf(next());
    }

    static long nextLong() throws IOException {
        return Long.valueOf(next());
    }

    private void run() throws IOException {
        solve();
    }

    int K, L, M, N, P;

    private void solve() throws IOException {
        int[][] road = new int[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                road[i][j] = nextInt();
            }
        }
        boolean can = false;
        for (int i = 0; i < 4; i++) {
            if (road[i][3] == 1 && (road[i][1] == 1 || road[i][0] == 1 || road[i][2] == 1 || road[(i-1+4)%4][2] == 1
                    || road[(i+1)%4][0] == 1 || road[(i+2)%4][1] == 1)){
                can = true;
                break;
            }
        }
        out.println(can?"YES":"NO");

    }

}

import java.util.*;

public class P1_601 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[][] r = new int[4][4];
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 4; j++) r[i][j] = scanner.nextInt();
		}

		ArrayList<Integer> risk = new ArrayList<Integer>();
		ArrayList<Integer> hit = new ArrayList<Integer>();

		for(int i = 0; i < 4; i++) {
			if(r[i][3]==1) risk.add(i);
		}
		//l, s, r
		for(int i = 0; i < 4; i++) {
			if(r[i][0]==1) {
				hit.add((i==0) ? 3 : i-1);
				hit.add(i);
			}
			if(r[i][1]==1) {
				hit.add((i==2||i==3) ? i-2 : i+2);
				hit.add(i);
			}
			if(r[i][2]==1) {
				hit.add((i==3) ? 0 : i+1);
				hit.add(i);
			}

		}
		for(int i = 0; i < risk.size(); i++) {
			if(hit.contains(risk.get(i))) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class crossRoads {
	public static void main(String[] args) throws IOException {
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line;
		int counter=0;
		int []r=new int[4];
		int []l=new int[4];
		int []s=new int[4];
		int []p=new int[4];
		for(int j=0;j<4;j++)
		{
			line=bf.readLine();
			String [] split=line.split(" ");
			l[counter]=Integer.parseInt(split[0]);
			s[counter]=Integer.parseInt(split[1]);
			r[counter]=Integer.parseInt(split[2]);
			p[counter++]=Integer.parseInt(split[3]);
		}
			for(int i=0;i<l.length;i++)
			{
				if(l[i]==1)
				{
					int target=i-1;
					if(target<0)
					{
						target+=4;
					}
					if((p[target]==1)||(p[i]==1))
					{
						System.out.println("YES");
						return;
					}
				}
				if(s[i]==1)
				{
					int target=i+2;
					if(target>3)
					{
						target-=4;
					}
					if(p[target]==1||(p[i]==1))
					{
						System.out.println("YES");
						return;
					}
				}

					if(r[i]==1)
					{
						int target=i+1;
						if(target>3)
						{
							target-=4;
						}
						if(p[target]==1||(p[i]==1))
						{
							System.out.println("YES");
							return;
						}
					}
			}
			System.out.println("NO");

		}
}

// CodeForces Round #453 A too Slow

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class SagheerCrossroads {

	boolean [] l,s,r,p;
	boolean accPos;

	private void readData(BufferedReader bin) throws IOException {
		String sss;
		String[] ss;
		// read k,l,m,n,d
		l = new boolean[4];
		s = new boolean[4];
		r = new boolean[4];
		p = new boolean[4];
		for (int i=0; i<4; i++) {
			sss = bin.readLine();
			ss = sss.split(" ");
			l[i] = (ss[0].charAt(0) == '1');
			s[i] = (ss[1].charAt(0) == '1');
			r[i] = (ss[2].charAt(0) == '1');
			p[i] = (ss[3].charAt(0) == '1');
		}
	}

	void printRes() {
		System.out.println(accPos ? "YES" : "NO" );
	}

	private void calculate() {
		accPos = false;
		for (int d=0; d<4; d++) {
			if (p[d]) {
				accPos = accPos || l[d] || s[d] || r[d];
				accPos |= l[(d+1) % 4];
				accPos |= s[(d+2) % 4];
				accPos |= r[(d+3) % 4];
			}
		}

	}

	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
		SagheerCrossroads l = new SagheerCrossroads();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}

// CodeForces Round #812 A too Slow

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class SagheerCrossroads {

	boolean [] l,s,r,p;
	boolean accPos;

	private void readData(BufferedReader bin) throws IOException {
		String sss;
		String[] ss;
		// read k,l,m,n,d
		l = new boolean[4];
		s = new boolean[4];
		r = new boolean[4];
		p = new boolean[4];
		for (int i=0; i<4; i++) {
			sss = bin.readLine();
			ss = sss.split(" ");
			l[i] = (ss[0].charAt(0) == '1');
			s[i] = (ss[1].charAt(0) == '1');
			r[i] = (ss[2].charAt(0) == '1');
			p[i] = (ss[3].charAt(0) == '1');
		}
	}

	void printRes() {
		System.out.println(accPos ? "YES" : "NO" );
	}

	private void calculate() {
		accPos = false;
		for (int d=0; d<4; d++) {
			if (p[d]) {
				accPos = accPos || l[d] || s[d] || r[d];
				accPos |= l[(d+1) % 4];
				accPos |= s[(d+2) % 4];
				accPos |= r[(d+3) % 4];
			}
		}

	}

	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
		SagheerCrossroads l = new SagheerCrossroads();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}

import java.io.*;
import java.util.*;

public class Solution{

 public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

     int i,j;
     int[][] a=new int[6][6];
     boolean accident=false;

     for(i=1;i<=4;i++){
    	 for(j=1;j<=4;j++){
    		 a[i][j]=Integer.parseInt(in.next());
    	 }
     }

     for(j=1;j<=4;j++){
    	 a[0][j]=a[4][j];
    	 a[5][j]=a[1][j];
     }

     for(i=1;i<=4;i++){
    	 int temp=0;
    	 for(j=1;j<=3;j++)temp+=a[i][j];
    	 if(temp>0 && a[i][4]==1)accident=true;

     }

     for(i=1;i<=4;i++){
    	 if(a[i][3]==1 && a[i+1][4]==1)accident=true;
    	 if(a[i][1]==1 && a[i-1][4]==1)accident=true;
    	 if(i<=2){
    		 if(a[i][2]==1 && a[i+2][4]==1)accident=true;
    		 if(a[i][4]==1 && a[i+2][2]==1)accident=true;
    	 }
     }

     if(accident){
    	 System.out.println("YES");
     }
     else{
    	 System.out.println("NO");
     }

 }
}

import java.util.Arrays;
import java.util.Scanner;

public class main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int[] r1 = new int[4];
		int[] r2 = new int[4];
		int[] r3 = new int[4];
		int[] r4 = new int[4];
		for(int i = 0;i<4;i++){
			r1[i]=in.nextInt();
		}
		for(int i = 0;i<4;i++){
			r2[i]=in.nextInt();
		}
		for(int i = 0;i<4;i++){
			r3[i]=in.nextInt();
		}
		for(int i = 0;i<4;i++){
			r4[i]=in.nextInt();
		}
		if(check(r1,r2,r3,r4)|| check(r2,r3,r4,r1)||check(r3,r4,r1,r2)||check(r4,r1,r2,r3)){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

	public static boolean check(int[] r1,int[] r2, int[] r3,int[] r4){
		boolean ret = false;
		if(r1[0]==1){
			if( r4[3]!=0  || r1[3]!=0){
				ret = true;
			}
		}
		if(r1[1]==1){
			if( r3[3]!=0   || r1[3]!=0){
				ret = true;
			}
		}

		if(r1[2]==1){
			if(r1[3]!=0 || r2[3]!=0){
				ret = true;
			}
		}

		return ret;
	}
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        int[][] a = new int[4][4];
        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 4; j++) {
                a[i][j] = kb.nextInt();
            }
        }
        boolean flag = false;
        for(int i = 0; i < 4; i++) {
            if(a[i][3] == 1 && (a[i][2] == 1 || a[i][1] == 1 || a[i][0] == 1 || a[(i+1)%4][0] == 1 || a[(i+2)%4][1] == 1 || a[(i+3)%4][2] == 1)) {
                flag = true;
            }
        }
        if(flag) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

import java.io.*;
import java.util.*;

public class SagheerAndCrossroads {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean[] car = new boolean[4];
		boolean[] ped = new boolean[4];
		for (int i = 0; i < 4; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int l = Integer.parseInt(st.nextToken());
			int s = Integer.parseInt(st.nextToken());
			int r = Integer.parseInt(st.nextToken());
			int p = Integer.parseInt(st.nextToken());
			// System.out.println(l+" "+s+" "+r+" "+p);
			boolean f = (l + s + r) > 0;
			if (p == 1 && f) {
				System.out.println("YES");
				return;
			}

			if (l == 1) {
				if (i == 0) {
					car[3] = true;
				} else {
					car[i - 1] = true;
				}
			}
			if (s == 1) {
				car[(i + 2) % 4] = true;
			}
			if (r == 1) {
				if (i == 3) {
					car[0] = true;
				} else {
					car[i + 1] = true;
				}
			}
			if (p == 1) {
				ped[i] = true;
			}
		}
		for (int i = 0; i < 4; i++) {
			if (car[i] && ped[i]) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}

import java.util.Scanner;

public class SagheerAndCrossroads {

    static Scanner scan= new Scanner(System.in);
    public static void main(String [] args){
        int [][] arr= new int[4][4];

        for(int i= 0; i< 4; i++) {
            boolean isOne = false;
            for (int j = 0; j < 4; j++) {
                arr[i][j] = scan.nextInt();
                if(arr[i][j] == 1) if(j == 3 && isOne){
                    System.out.println("YES");
                    return;
                }
                else isOne = true;
            }
        }

        if(arr[0][3] == 1 && (arr[1][0] == 1 || arr[2][1] == 1 || arr[3][2] == 1))
            System.out.println("YES");
        else if(arr[1][3] == 1 && (arr[0][2] == 1 || arr[3][1] == 1 || arr[2][0] == 1))
            System.out.println("YES");
        else if(arr[2][3] == 1 && (arr[0][1] == 1 || arr[1][2] == 1 || arr[3][0] == 1))
            System.out.println("YES");
        else if(arr[3][3] == 1 && (arr[0][0] == 1 || arr[1][1]== 1 || arr[2][2] == 1))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

import java.util.*;
import java.io.*;

public class roads {
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;
        public InputReader() throws FileNotFoundException {
            // reader = new BufferedReader(new FileReader("count.in"));
            reader = new BufferedReader (new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        String next() { // reads in the next String
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() { // reads in the next int
            return Integer.parseInt(next());
        }
        public long nextLong() { // reads in the next long
            return Long.parseLong(next());
        }
        public double nextDouble() { // reads in the next double
            return Double.parseDouble(next());
        }
    }

    public static void main (String[] args) throws IOException, FileNotFoundException {
	InputReader in = new InputReader();
        PrintWriter pw = new PrintWriter(System.out);
        boolean[][] roads = new boolean[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                roads[i][j] = in.nextInt() == 1;
            }
        }

        if (roads[0][3] && (roads[3][2] || roads[2][1] || roads[1][0] || roads[0][0] || roads[0][1] || roads[0][2])) {
           pw.println("YES");
        }
        else if (roads[1][3] && (roads[0][2] || roads[3][1] || roads[2][0] || roads[1][0] || roads[1][1] || roads[1][2])) {
           pw.println("YES");
        }
        else if (roads[2][3] && (roads[1][2] || roads[0][1] || roads[3][0] || roads[2][0] || roads[2][1] || roads[2][2])) {
           pw.println("YES");
        }
        else if (roads[3][3] && (roads[2][2] || roads[1][1] || roads[0][0] || roads[3][0] || roads[3][1] || roads[3][2])) {
           pw.println("YES");
        }
        else pw.println("NO");
	pw.close();
    }
}

import java.util.*;

public class TaskA {
  public static void main (String[] args) {
    Scanner scan = new Scanner(System.in);
    int l1 = scan.nextInt();
    int s1 = scan.nextInt();
    int r1 = scan.nextInt();
    int p1 = scan.nextInt();

    int l2 = scan.nextInt();
    int s2 = scan.nextInt();
    int r2 = scan.nextInt();
    int p2 = scan.nextInt();

    int l3 = scan.nextInt();
    int s3 = scan.nextInt();
    int r3 = scan.nextInt();
    int p3 = scan.nextInt();

    int l4 = scan.nextInt();
    int s4 = scan.nextInt();
    int r4 = scan.nextInt();
    int p4 = scan.nextInt();

    if((s1==1&&p3==1)||(s2==1&&p4==1)||(s3==1&&p1==1)||(s4==1&&p2==1)) {
      System.out.println("YES");
    }
    else if((r1==1&&p2==1)||(r2==1&&p3==1)||(r3==1&&p4==1)||(r4==1&&p1==1)) {
      System.out.println("YES");
    }
    else if((l1==1&&p4==1)||(l2==1&&p1==1)||(l3==1&&p2==1)||(l4==1&&p3==1)) {
      System.out.println("YES");
    }
    else if((s1==1&&p1==1)||(l1==1&&p1==1)||(r1==1&&p1==1)) {
      System.out.println("YES");
    }
    else if((s2==1&&p2==1)||(l2==1&&p2==1)||(r2==1&&p2==1)) {
      System.out.println("YES");
    }
    else if((s3==1&&p3==1)||(l3==1&&p3==1)||(r3==1&&p3==1)) {
      System.out.println("YES");
    }
    else if((s4==1&&p4==1)||(l4==1&&p4==1)||(r4==1&&p4==1)) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }

  }
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A
{
	static PrintWriter out = new PrintWriter(
			new BufferedOutputStream(System.out));
	static MyScanner sc = new MyScanner(System.in);
	static StringBuilder output = new StringBuilder();

	public static void main(String... args)
	{
		boolean[][] lights = new boolean[4][4];
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				lights[i][j] = sc.nextInt() == 1;
			}
		}

		for (int s = 0; s < 4; s++)
		{
			if (lights[0][2] && lights[1][3] ||
				lights[0][1] && lights[2][3] ||
				lights[0][0] && lights[3][3] ||
				lights[0][3] && lights[0][0] ||
				lights[0][3] && lights[0][1] ||
				lights[0][3] && lights[0][2])
			{
				output.append("YES\n");

				eOP();
			}

			//swap
			boolean[] temp = lights[0];
			lights[0] = lights[1];
			lights[1] = lights[2];
			lights[2] = lights[3];
			lights[3] = temp;
		}

		output.append("NO\n");

		eOP();
	}

	private static void eOP()
	{
		System.out.println(output);
		System.exit(0);
	}

	/**
	 * Flatfoot's Scanner with slight modifications.
	 *
	 * @author Flatfoot
	 * @see Source
	 */
	private static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;

		MyScanner(InputStream in)
		{
			this.br = new BufferedReader(new InputStreamReader(in));
		}

		String next()
		{
			while (this.st == null || !this.st.hasMoreElements())
			{
				try
				{
					this.st = new StringTokenizer(this.br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return this.st.nextToken();
		}

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

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

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

		/**
		 * This method has been modified to be a bit more similar to Scanner's
		 *
		 * @author Flatfoot,
		 *         JasonBaby
		 */
		String nextLine()
		{
			if (this.st == null || !this.st.hasMoreElements())
			{
				String str = "";
				try
				{
					str = this.br.readLine();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
				return str;
			}
			else
			{
				StringBuilder str = new StringBuilder();
				while (this.st.hasMoreElements())
				{
					str.append(this.st.nextToken());
					str.append(" ");
				}
				str.deleteCharAt(str.length() - 1);
				return str.toString();
			}
		}

	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s[] = in.nextLine().split(" ");
            int l1 = Integer.valueOf(s[0]);
            int s1 = Integer.valueOf(s[1]);
            int r1 = Integer.valueOf(s[2]);
            int p1 = Integer.valueOf(s[3]);
            s = in.nextLine().split(" ");
            int l2 = Integer.valueOf(s[0]);
            int s2 = Integer.valueOf(s[1]);
            int r2 = Integer.valueOf(s[2]);
            int p2 = Integer.valueOf(s[3]);
            s = in.nextLine().split(" ");
            int l3 = Integer.valueOf(s[0]);
            int s3 = Integer.valueOf(s[1]);
            int r3 = Integer.valueOf(s[2]);
            int p3 = Integer.valueOf(s[3]);
            s = in.nextLine().split(" ");
            int l4 = Integer.valueOf(s[0]);
            int s4 = Integer.valueOf(s[1]);
            int r4 = Integer.valueOf(s[2]);
            int p4 = Integer.valueOf(s[3]);

            String rez = "NO";
            if (p1 == 1 && (s1 == 1 || l1 == 1 || r1 == 1 || l2 == 1 || s3 == 1 || r4 == 1)) {
                rez = "YES";
            }
            if (p2 == 1 && (s2 == 1 || l2 == 1 || r2 == 1 || l3 == 1 || s4 == 1 || r1 == 1)) {
                rez = "YES";
            }
            if (p3 == 1 && (s3 == 1 || l3 == 1 || r3 == 1 || l4 == 1 || s1 == 1 || r2 == 1)) {
                rez = "YES";
            }
            if (p4 == 1 && (s4 == 1 || l4 == 1 || r4 == 1 || l1 == 1 || s2 == 1 || r3 == 1)) {
                rez = "YES";
            }
            out.println(rez);
        }

    }
}

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
	    Scanner stream=new Scanner(System.in);
        int[][] m=new int[4][4];
        for (int i=0;i<4;i++)
                    for (int j=0;j<4;j++)
                        m[i][j]=stream.nextInt();
        System.out.println(check(m));
    }
    static String check ( int[][] m)
    {
        for(int i=0;i<4;i++)
        {
            if(m[i][3]==1)
            {
                for (int j=0;j<3;j++)
                {
                    if(m[i][j]==1)
                        return "YES";
                }
                if(m[(i+2)%4][1]==1 || m[(i+1)%4][0]==1 || m[(i+3)%4][2]==1 )
                    return "YES";
            }
        }
        return "NO";
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[][] a = new int[4][4];
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    a[i][j] = in.nextInt();
                }
            }
            for (int i = 0; i < 4; i++) {
                if (a[i][3] == 1) {
                    if (a[(i + 1) % 4][0] == 1 || a[(i + 2) % 4][1] == 1 || a[(i + 3) % 4][2] == 1 ||
                            a[i][1] == 1 || a[i][0] == 1 || a[i][2] == 1) {
                        out.println("YES");
                        return;
                    }
                }
            }
            out.println("NO");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

import java.util.Scanner;

public class scorify {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int tab[][] = new int[4][3];
		char stat[] = new char[4];
		for (int i = 0; i < tab.length; i++) {
			for (int j = 0; j < tab[0].length; j++) {
				tab[i][j] = in.nextInt();
			}
			stat [i]= in.next().charAt(0);
		}
		String pat[] ={"1012","2101","1210","0121"};

		for (int i = 0; i < 4; i++) {
			if(stat[i] == '1'){
				for (int j = 0; j < 3; j++) {
					if(tab[i][j] == 1){
						System.out.println("YES");
						return ;
					}
				}
				for (int j = 0; j < 4; j++) {
					if(tab[j][Integer.parseInt(pat[i].charAt(j)+"")] == 1 ){
						System.out.println("YES");
						return ;
					}
				}
			}
		}
		System.out.println("NO");

	}
}

import java.util.Scanner;

public class A812 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		boolean[] lanes = new boolean[16];
		boolean[] pedestrian = new boolean[4];
		for(int i = 0; i < 16; i++) {
			if(i % 4 != 3)
				if(scanner.nextInt() == 1)
					lanes[i] = true;
				else
					lanes[i] = false;
			else
				if(scanner.nextInt() == 1)
					pedestrian[i / 4] = true;
				else
					pedestrian[i / 4] = false;
		}

		String result = meetsRequirements(lanes, pedestrian) ? "NO" : "YES";
		System.out.print(result);
	}

	private static boolean meetsRequirements(boolean[] lanes, boolean[] pedestrian) {
		for(int i = 0; i < 16; i++) {
			int row = i / 4;
			int column = i % 4;
			int position = 0;
			if(lanes[i]) {
				if(pedestrian[row])
					return false;
				switch(column) {
					case 0:
						position = (row + 3) % 4;
						if(pedestrian[position])
							return false;
						break;
					case 1:
						position = (row + 2) % 4;
						if(pedestrian[position])
							return false;
						break;
					case 2:
						position = (row + 1) % 4;
						if(pedestrian[position])
							return false;
						break;
				}

			}
		}
		return true;
	}
}

import java.util.Scanner;
public class SagheerandCrossroads {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean Safe = true;
		int [][] arr = new int [4][4];
		for (int i = 0; i < arr.length; i++) {
			for (int j = 0; j < arr.length; j++) {
				arr[i][j] = sc.nextInt();
			}	}
		for (int i = 0; i < 4; i++) {
			if (arr[i][3]==1)
			{
				if (arr[i][0]==1 || arr[i][1]==1 ||arr[i][2]==1 )
					Safe=false;
				if (arr[(i+2)%4][1]==1)
					Safe=false;
				if (arr[(i+1)%4][0]==1)
					Safe =false;
				if (arr[(i+3)%4][2]==1)
					Safe =false;
			}}
			if (Safe)
				System.out.println("NO");
			else
				System.out.println("YES");

	}

}

import java.io.*;
import java.util.*;

public class A {
    public static void solution(BufferedReader reader, PrintWriter writer)
            throws IOException {
        In in = new In(reader);
        Out out = new Out(writer);
        int[][] data = new int[4][4];
        for (int i = 0; i < 4; i++)
            data[i] = in.nextIntArray(4);
        boolean ok = true;
        for (int i = 0; i < 4; i++) {
            if (data[i][0] == 1
                    && (data[(i + 3) % 4][3] == 1 || data[i][3] == 1))
                ok = false;
            if (data[i][2] == 1
                    && (data[(i + 1) % 4][3] == 1 || data[i][3] == 1))
                ok = false;
            if (data[i][1] == 1
                    && (data[(i + 2) % 4][3] == 1 || data[i][3] == 1))
                ok = false;
        }
        out.println(ok ? "NO" : "YES");
    }

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(
                new BufferedWriter(new OutputStreamWriter(System.out)));
        solution(reader, writer);
        writer.close();
    }

    protected static class In {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public In(BufferedReader reader) {
            this.reader = reader;
        }

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

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

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

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

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray1(int n) throws IOException {
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArraySorted(int n) throws IOException {
            int[] a = nextIntArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArray1(int n) throws IOException {
            long[] a = new long[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArraySorted(int n) throws IOException {
            long[] a = nextLongArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                long t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }
    }

    protected static class Out {
        private PrintWriter writer;
        private static boolean local = System
                .getProperty("ONLINE_JUDGE") == null;

        public Out(PrintWriter writer) {
            this.writer = writer;
        }

        public void print(char c) {
            writer.print(c);
        }

        public void print(int a) {
            writer.print(a);
        }

        public void printb(int a) {
            writer.print(a);
            writer.print(' ');
        }

        public void println(Object a) {
            writer.println(a);
        }

        public void println(Object[] os) {
            for (int i = 0; i < os.length; i++) {
                writer.print(os[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(int[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(long[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void flush() {
            writer.flush();
        }

        public static void db(Object... objects) {
            if (local)
                System.out.println(Arrays.deepToString(objects));
        }
    }
}

import java.util.*;
public class adi
{
	public static void main(String[] args) {
		long l=0;
		Scanner s=new Scanner(System.in);
		int a[][]=new int[4][4];
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<4;j++)
			{
				a[i][j]=s.nextInt();
			}
		}
		int f=0;
		for(int i=0;i<4;i++)
		{

				if(a[i][3]==0)
					continue;
				else
				{
					for(int j=0;j<3;j++)
					{
						if(a[i][j]==1)
						{
							System.out.println("YES");
							return;
						}

					}
					int x=2;
					int k=i-1;
					while(x>=0)
					{

						if(k==-1)
							k=3;
						if(a[k][x]==1)
						{
							System.out.println("YES");
							return;
						}
						k--;
						x--;
					}

				}

		}
		System.out.println("NO");

	}
}

import java.util.*;

public class A812 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = 4;

		int[][] mat = new int[n][n];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				mat[i][j] = scan.nextInt();
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n - 1; j++) {
				if (mat[i][j] == 1) {
					if (mat[i][n-1] == 1) {
						System.out.println("YES");
						System.exit(0);
					}
					for (int k = 0; k < n; k++) {
						if ((j - i + n) % n == k && mat[(3 - k)][n-1] == 1) {
							System.out.println("YES");
							System.exit(0);
						}
					}
				}
			}
		}

		System.out.print("NO");
	}
}

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

public class cf1 {
	 static class pair implements Comparable<pair>
		{
			Integer x,y;
			pair(int x,int y)
			{
				this.x=x;
				this.y=y;
			}
			public int compareTo(pair o) {
				if(y!=o.y)
					return y.compareTo(o.y);
				else
					return x.compareTo(o.x);
			}
		}
	static long mod=1000000007;
	static boolean prime[];
	public static void main(String args[])
	{
		InputReader in=new InputReader(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int[][] arr=new int[4][4];
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<4;j++)
				arr[i][j]=in.nextInt();
		}
		boolean flag=true;
		if(arr[0][0]==1 || arr[1][1]==1 || arr[2][2]==1 || arr[3][0]==1 || arr[3][1]==1 || arr[3][2]==1)
		{
			if(arr[3][3]==1)
				flag=false;
		}
		if(arr[0][1]==1 || arr[1][2]==1 || arr[2][0]==1 || arr[2][1]==1 || arr[2][2]==1 || arr[3][0]==1)
		{
			if(arr[2][3]==1)
				flag=false;
		}
		if(arr[0][2]==1 || arr[1][0]==1 || arr[1][1]==1 || arr[1][2]==1 || arr[2][0]==1 || arr[3][1]==1)
		{
			if(arr[1][3]==1)
				flag=false;
		}
		if(arr[0][0]==1 || arr[0][1]==1 || arr[0][2]==1 || arr[1][0]==1 || arr[2][1]==1 || arr[3][2]==1)
		{
			if(arr[0][3]==1)
				flag=false;
		}
		if(flag)
			pw.print("NO");
		else
			pw.println("YES");
		pw.flush();
	}
	public static boolean check(char[] str)
	{
		if(str[0]!=str[4])
			return false;
		if(str[1]!=str[3])
			return false;
		return true;
	}
	public static int distance(int x,int y,int p,int q)
	{
		int a=(x-p)*(x-p);
		int b=(y-q)*(y-q);
		int dis=a+b;
		return dis;
	}
	public static int bnum(int num)
	{
		int ans=0;
		for(int i=31;i>=0;i--)
		{
			if((num&(1<<i))!=0)
			{
				ans+=Math.pow(10,i);
			}
		}
		return ans;
	}
	public static int bsdown(int a[],int item)
	{
		int low=0,high=a.length-1,ans=-1;
		while(low<=high)
		{
			int mid=low+(high-low)/2;
			if(a[mid]<=item)
			{
				ans=mid;
				low=mid+1;
			}
			else
				high=mid-1;

		}
		return ans;
	}
	public static long inverse(long num)
	{
		return fastpow(num,mod-2,mod);
	}
	public static int bsupper(int a[],int item)
	{
		int low=0,high=a.length-1,ans=-1;
		while(low<=high)
		{
			int mid=low+(high-low)/2;
			if(a[mid]>=item)
			{
				ans=mid;
				high=mid-1;
			}
			else
				low=mid+1;

		}
		return ans;
	}
	public static boolean isprime(int n)
	{
		for(int i=2;i*i<=n;i++)
		{
			if(n%i==0)
				return false;
		}
		return true;
	}
	public static long fact(long a,long mod)
	{
		long ans=1;
		for(int i=1;i<=a;i++)
		{
			ans*=i;
			ans%=mod;
		}
		return ans%mod;

	}
	public static long ncr(long n,long r,long mod)
	{
		long nom=1,dom=1;
		nom=(fact(n,mod))%mod;
		dom=(fact(r,mod)*fact(n-r,mod))%mod;
		return (nom*fastpow(dom,mod-2,mod))%mod;
	}
	public static long gcd(long x, long y)
	{
		if(x==0)
			return y;
		if(y==0)
			return x;
		long r=0, a, b;
		a = (x > y) ? x : y; // a is greater number
		b = (x < y) ? x : y; // b is smaller number
		r = b;
		while(a % b != 0)
		{
			r = a % b;
			a = b;
			b = r;
		}
		return r;
	}
	public static void prime(int n)
	{
		prime[0]=true;
		prime[1]=true;
		for(int i=2;i*i<=n;i++)
		{
			if(prime[i])
				continue;
			for(int j=i;j*i<=n;j++)
			{
				prime[i*j]=true;
			}
		}
	}
	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
	public static long fastpow(long a,long b,long mod)
	{
		long ans=1;
		while(b!=0)
		{
			if(b%2==1)
			{
				ans=(ans*a)%mod;
			}
			a=(a*a)%mod;
			b/=2;
		}
		return ans;
	}
}

import java.util.Scanner;

public class Solution {

	public int calc() throws Exception
	{
		Scanner sc = new Scanner(System.in);

		int[][] mtx = new int [4][4];

		for (int i = 0; i < 4; i++)
		{
			int l = sc.nextInt();
			int s = sc.nextInt();
			int r = sc.nextInt();
			int p = sc.nextInt();

			mtx[i][0] = l;
			mtx[i][1] = s;
			mtx[i][2] = r;
			mtx[i][3] = p;
		}

		int ans = 0;
		for (int i = 0; i < 4; i++)
		{
			int il = i-1;
			if (il < 0)
				il = 3;

			int ir = i + 1;
			if (ir >= 4)
				ir = 0;

			int iff = i + 2;
			if (iff >= 4)
				iff -= 4;

			if (mtx[i][0] == 1 && (mtx[i][3] == 1 || mtx[il][3] ==1 ))
			{
				ans = 1;
				break;
			}

			if (mtx[i][1] == 1 && (mtx[i][3]==1 || mtx[iff][3] == 1))
			{

				//System.out.println(i + " " +mtx[i][1]  );
				//System.out.println((mtx[iff][3] == 1) + " "+iff);
				ans = 1;
				break;
			}

			if (mtx[i][2]==1 && (mtx[i][3]==1 || mtx[ir][3] == 1))
			{
				ans = 1;
				break;
			}
		}

		return ans;
	}

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub

		Solution sol = new Solution();

		if (sol.calc() == 1)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}

import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		while (sc.hasNext()) {
			int[][]c=new int[4][4];
			boolean flag=true;
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					c[i][j]=sc.nextInt();
				}
			}
			for(int i=0;i<4;i++){
				if(c[i][0]==1||c[i][1]==1||c[i][2]==1){
					if(c[i][3]==1){
						flag=false;
						break;
					}
				}
			}
			for(int i=0;i<4;i++){
				if(c[i][0]==1){
					if(c[(i-1+4)%4][3]==1){
						flag=false;
						break;
					}
				}
			}
			for(int i=0;i<4;i++){
				if(c[i][2]==1){
					if(c[(i+1)%4][3]==1){
						flag=false;
						break;
					}
				}
			}
			for(int i=0;i<4;i++){
				if(c[i][1]==1){
					if(c[(i+2)%4][3]==1){
						flag=false;
						break;
					}
				}
			}
			if(flag)pw.println("NO");
			else pw.println("YES");
			pw.flush();
		}
	}
}

class FastScanner {
	BufferedReader br;
	StringTokenizer st;

	public FastScanner() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer("");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String line = nextLine();
			if (line == null) {
				return false;
			}
			st = new StringTokenizer(line);
		}
		return true;
	}

	public String next() {
		while(!st.hasMoreTokens()){
			st=new StringTokenizer(nextLine());
		}
		return st.nextToken();
	}

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

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

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

	public String nextLine() {
		String line = "";
		try {
			line = br.readLine();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return line;
	}
}

import java.awt.Point;
import java.awt.Polygon;
import java.io.PrintWriter;
import java.util.Scanner;

public class AnswerChecker {

	public static void main(String[] args) {

		Scanner  in = new Scanner(System.in);

		boolean[][] on = new boolean[4][4];

		for(int i=0; i<4; i++) {
			boolean go = false;
			for(int j=0; j<4; j++) {
				on[i][j] = (in.nextInt() == 1);

				if(j == 3) {
					if(on[i][j] && go) {
						System.out.println("YES");
						return;
					}
				}
				else {
					go |= on[i][j];

				}
			}
		}

		for(int i=0; i<4; i++) {
			if(!on[i][3]) {
				continue;
			}

			for(int j=1; j<=3; j++) {
				if(on[(i + j) % 4][j-1]) {
					System.out.println("YES");
					return;
				}
 			}
		}

		System.out.println("NO");

	}
}

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

public class Main {

 public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int[][] a=new int[4][4];
     for(int i = 0 ;   i < 4 ; i++ ){
         for(int j = 0 ; j < 4 ; j++){
             a[i][j] = sc.nextInt();
         }
     }
     boolean ok = false;
     loop:
     for(int i = 0 ; i < 4 ; i++){
         if(a[i][3]==1){
             for(int j = 0 ; j < 3 ; j++){
                 if(a[(j+i+1)%4][j]==1 || a[i][j]==1){
                     ok = true;
                     break loop;
                 }
             }
         }
     }
     System.out.println(ok ? "YES" : "NO");
   }
}

import java.util.Scanner;

public class A812 {

	static Scanner sc = new Scanner(System.in);
	static int[][] a = new int[4][4];

	static boolean accident() {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] + a[i][3] == 2)
					return true;
				if (a[(i + j + 1) % 4][j] + a[i][3] == 2)
					return true;
			}
		}
		return false;
	}

	public static void main(String[] args) {
		for(int i = 0;i<4;i++)
			for(int j = 0;j<4;j++)
				a[i][j] = sc.nextInt();

		if (accident())
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sid
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        A812 solver = new A812();
        solver.solve(1, in, out);
        out.close();
    }

    static class A812 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {

            int arr[][] = new int[4][4];
            int count = 0;
            int flag = 0;
            for (int i = 0; i < 4; i++) {
                count = 0;
                for (int j = 0; j < 4; j++) {
                    arr[i][j] = in.nextInt();
                    if (arr[i][j] == 1)
                        count++;
                }
                if (arr[i][3] == 1 && count > 1)
                    flag = 1;
            }

            if (flag == 0 && arr[0][3] == 1) {
                if (arr[1][0] == 1 || arr[2][1] == 1 || arr[3][2] == 1)
                    flag = 1;
            }
            if (flag == 0 && arr[1][3] == 1) {
                if (arr[0][2] == 1 || arr[2][0] == 1 || arr[3][1] == 1)
                    flag = 1;
            }
            if (flag == 0 && arr[2][3] == 1) {
                if (arr[0][1] == 1 || arr[1][2] == 1 || arr[3][0] == 1)
                    flag = 1;
            }
            if (flag == 0 && arr[3][3] == 1) {
                if (arr[0][0] == 1 || arr[1][1] == 1 || arr[2][2] == 1)
                    flag = 1;
            }
            if (flag == 1)
                out.println("YES");
            else
                out.println("NO");

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.io.*;
import java.util.*;

public class Main {
	static int[][] road;
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;

		road = new int[4][4];
		for(int i=0;i<4;i++){
			st = new StringTokenizer(br.readLine());
			for(int j=0;j<4;j++){
				road[i][j] = Integer.parseInt(st.nextToken());
			}
		}
		boolean acc = false;
		if(road[0][0]==1 && ( road[3][3]==1 || road[0][3]==1))
			acc = true;
		if(road[0][1]==1 &&  ( road[2][3]==1 || road[0][3]==1))
			acc = true;
		if(road[0][2]==1 && ( road[1][3]==1 || road[0][3]==1))
			acc = true;

		if(road[1][0]==1 && ( road[0][3]==1 || road[1][3]==1))
			acc = true;
		if(road[1][1]==1 && ( road[3][3]==1 || road[1][3]==1))
			acc = true;
		if(road[1][2]==1 && ( road[2][3]==1 || road[1][3]==1))
			acc = true;

		if(road[2][0]==1 && ( road[1][3]==1 || road[2][3]==1))
			acc = true;
		if(road[2][1]==1 && ( road[0][3]==1 || road[2][3]==1))
			acc = true;
		if(road[2][2]==1 && ( road[3][3]==1 || road[2][3]==1))
			acc = true;

		if(road[3][0]==1 && ( road[2][3]==1 || road[3][3]==1))
			acc = true;
		if(road[3][1]==1 && ( road[1][3]==1 || road[3][3]==1))
			acc = true;
		if(road[3][2]==1 && ( road[0][3]==1 || road[3][3]==1))
			acc = true;

		if(acc)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static final int SIZE = 4;
    private static PrintWriter out;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        InputData[] inputDatas = new InputData[SIZE];

        for (int i = 0; i < inputDatas.length; i++) {
            inputDatas[i] = new InputData(sc.nextLine());
        }

        String answer = null;
        for (int i = 0; i < SIZE; i++) {
            if (!inputDatas[i].p)
                continue;
            for (int j = 0; j < SIZE; j++) {
                if (parseRoadNumber(j, inputDatas[(i + j) % SIZE])) {
                    answer = "YES";
                }
            }
        }

        if (answer == null) {
            answer = "NO";
        }

        out.println(answer);
        out.close();
    }

    private static boolean parseRoadNumber(int i, InputData data) {
        switch (i) {
            case 0:
                return data.s || data.l || data.r;
            case 2:
                return data.s;
            case 1:
                return data.l;
            case 3:
                return data.r;
            default:
                return data.r;
        }
    }

    static class InputData {
        final boolean l;
        final boolean s;
        final boolean r;
        final boolean p;

        InputData(String data) {
            final String[] split = data.split(" ");

            l = parseData(split[0]);
            s = parseData(split[1]);
            r = parseData(split[2]);
            p = parseData(split[3]);
        }

        private boolean parseData(String d) {
            return "1".equals(d);
        }
    }

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

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

public class _417div2Q1
{
    public static void main(String[] args) throws IOException
    {
        FastScanner obj = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

		int[] l = new int[4];
		int[] s = new int[4];
		int[] r = new int[4];
		int[] p = new int[4];

		for(int i=0;i<4;i++)
		{
			l[i] = obj.nextInt();
			s[i] = obj.nextInt();
			r[i] = obj.nextInt();
			p[i] = obj.nextInt();
		}
		String ans = "NO";
		for(int i =0;i<4;i++)
		{
			if(p[i]==1)
			{
				if(l[(i+1)%4]==1 || s[(i+2)%4]==1 || r[(i+3)%4]==1)
					ans = "YES";
				else if(l[i]==1 || r[i]==1 || s[i]==1)
					ans = "YES";
			}
		}
		out.println(ans);
        out.close();
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;

   //-----------FastScanner class for faster input----------
   public static class FastScanner {
        BufferedReader br;
        StringTokenizer tokenizer;

        public FastScanner() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = new StringTokenizer(br.readLine().trim());
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    }
            }
          return tokenizer.nextToken();
        }

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

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

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

        int[] nextIntArray() throws IOException {
            String[] line = br.readLine().trim().split(" ");
            int[] out = new int[line.length];

            for (int i = 0; i < line.length; i++) {
                out[i] = Integer.valueOf(line[i]);
            }
            return out;
        }

        BigInteger nextBigInteger() throws IOException {
            return new BigInteger(next());
        }

        String nextLine(){
            String str = "";
	        try {
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
        }

   }
   //--------------------------------------------------------
}

import java.io.*;
import java.util.*;
public class A {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);

		boolean [] [] a=new boolean [4][4];
		for(int i=0;i<4;i++)
			for(int j=0;j<4;j++)
				a[i][j]=sc.nextInt()==1;
		boolean f=false;
		for(int i=0;i<4;i++){
			if(a[i][3]){
				if(a[i][0] || a[i][1] || a[i][2])
					f=true;
				if(a[(i+2)%4][1])
					f=true;
				if(a[(i+1)%4][0])
					f=true;
				if(a[(i+3)%4][2])
					f=true;
			}
		}
		pw.println(f? "YES" : "NO");
		pw.flush();
		pw.close();
	}

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {br = new BufferedReader(new InputStreamReader(System.in));}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class Main{
	static class cost implements Comparable<cost>{
		int prev,cur;
		cost(int x,int y){
			prev=x;
			cur=y;
		}
		@Override
		public int compareTo(cost ob){
			int diff1=this.cur-this.prev;
			int diff2=ob.cur-ob.prev;
			if(diff1>=0 && diff2>=0){
				if(diff1>diff2)
					return -1;
				else
					return 1;
			}
			if(diff1>=0)
				return -1;
			if(diff2>=0)
				return 1;
			if(diff1<0 && diff2<0){
				if(diff1<diff2)
					return 1;
				return -1;
			}
			return 0;
		}
	}
	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
	public static void main(String args[])throws IOException{
		Reader in=new Reader();
		int[] ped=new int[4];
		int[] busy=new int[4];
		for(int i=0;i<4;i++){
			int a=in.nextInt();
			int b=in.nextInt();
			int c=in.nextInt();
			ped[i]=in.nextInt();
			if(i==0){
				if(a==1)
					busy[3]=1;
				if(b==1)
					busy[2]=1;
				if(c==1)
					busy[1]=1;
			}
			if(i==1){
				if(a==1)
					busy[0]=1;
				if(b==1)
					busy[3]=1;
				if(c==1)
					busy[2]=1;
			}
			if(i==2){
				if(a==1)
					busy[1]=1;
				if(b==1)
					busy[0]=1;
				if(c==1)
					busy[3]=1;
			}
			if(i==3){
				if(a==1)
					busy[2]=1;
				if(b==1)
					busy[1]=1;
				if(c==1)
					busy[0]=1;
			}
			if(a==1 || b==1 || c==1)
				busy[i]=1;
		}
		for(int i=0;i<4;i++){
			if(busy[i]==1 && ped[i]==1){
				System.out.println("YES");
				System.exit(0);
			}
		}
		System.out.println("NO");
	}
}

/**
 *
 * @author bossbelik
 */
        import java.io.*;
        import java.util.*;
        import java.math.*;
        import java.util.concurrent.ThreadLocalRandom;

public class Main {
    static long N = 100;
    static long CNT = 62;
    static long INF = 1 << 62;

    static long parsenum(long j, long l) {
        String k = "";
        long cur = 0;
        for (int i = (int) j; i <= l; ++i) {
            cur *= 10;
            cur += k.charAt(i) - '0';
        }
        return cur;
    }

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

    static boolean pri(int k) {
        if (k == 1) return false;
        for (int i = 2; i * i <= k; i++) {

            if (k % i == 0) return false;
        }
        return true;
    }

    static long solve(int x, int y, int p, int q)
    {
        if ((p == q && x != y) || (p == 0 && x != 0)) return -1;
        long l = (y + q - 1) / q - 1, r = 1L << 30;
        while (l < r - 1) {
            long mid = (l + r) >> 1;
            long last = mid * q;
            long num = mid * p;
            long have = last - y;
            if (num <= have + x && num >= x)
                r = mid;
            else l = mid;
        }
        long last = r * q;
        long have = last - y;
        return have;
    }

    public static void main(String[] args) throws Exception
    {

//
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter((System.out));

        //  Scanner in = new Scanner(new File("rect.in"));
        //   PrintWriter out = new PrintWriter(new File("rect.out"))

        int a[][] = new int[4][4];

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    a[i][j] = in.nextInt();
                }
            }
            for (int i = 0; i < 4; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    if (a[i][j] == 1 && a[i][3] == 1)
                    {
                        out.println("YES");
                        out.close();
                        return;
                    }
                }
            }
            for (int i = 0; i < 4; ++i)
            {
                int p = (i + 1) % 4;
                if (a[p][3] > 0 && a[i][2] > 0)
                {
                    out.println("YES");
                    out.close();
                    return;
                }
                int u = (i + 3) % 4;
                if (a[u][3] > 0  && a[i][0] > 0)
                {
                    out.println("YES");
                    out.close();
                    return;
                }

                p = (i + 2) % 4;
                if (a[p][3] > 0 && a[i][1] > 0)
                {
                    out.println("YES");
                    out.close();
                    return;
                }
            }
        {
            {
                out.println("NO");
                out.close();
                return;
            }
        }

        }
}

import java.util.Scanner;

public class A812 {
    static int f(int a){
        if(a<1){
            return a+4;
        }
        if(a>4){
            return a-4;
        }
        return a;
    }
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int p[]=new int[5];
        int tp[]=new int[5];
        for(int i=1;i<=4;i++){
            int l=sc.nextInt();
            int c=sc.nextInt();
            int r=sc.nextInt();
            if(l==1){
                tp[f(i-1)]=1;
            }
            if(c==1){
                tp[f(i+2)]=1;
            }
            if(r==1){
                tp[f(i+1)]=1;
            }
            if(l==1 || c==1 || r==1){
                tp[i]=1;
            }
            p[i]=sc.nextInt();
        }
        boolean cd =true;
        for(int i=1;i<5;i++){
            if(p[i]==1 && tp[i]==1){
                cd=false;
                break;
            }
        }
        if(cd){
            System.out.println("NO");
        }
        else{
            System.out.println("YES");
        }
    }
}

	// Code Author: Rutul Patel
import java.io.*;
	import java.math.BigInteger;
	import java.math.RoundingMode;
	import java.text.DecimalFormat;
	import java.util.*;

public class Main {

		static double eps=(double)1e-6;
		static long mod=(int)1e9+6;
		static ArrayList<Integer>[] list=new ArrayList[1000003];
		static int[] dist=new int[1000003];
		public static void main(String args[]) throws IOException{
			InputReader sc = new InputReader(System.in);
			OutputStream outputStream = System.out;
			PrintWriter out = new PrintWriter(outputStream);
			//-------------------------------------

			int[][] arr=new int[5][5];
			for(int i=1;i<=4;i++)
			{
				for(int j=1;j<=4;j++)
					arr[i][j]=sc.nextInt();
			}

			boolean[] can=new boolean[5];
			for(int i=1;i<=4;i++)
			{
				for(int j=1;j<=3;j++)
				{
					if(arr[i][j]==1)
						can[i]=true;
					if(j==1 && arr[i][j]==1)
					{
						int l=i-1;
						if(l==0)
							l=4;
						can[l]=true;
					}
					else if(j==2 && arr[i][j]==1)
					{
						int s=(i+2)%4;
						if(s==0)
							s=4;
						can[s]=true;
					}
					else if(arr[i][j]==1)
					{
						int r=(i+1)%4;
						if(r==0)
							r=4;
						can[r]=true;
					}
				}
				/*for(int k=1;k<=4;k++)
					out.print(can[k]+" ");
				out.println();*/
			}
			/*for(int i=1;i<=4;i++)
				out.print(can[i]+" ");*/
			boolean ans=true;
			for(int i=1;i<=4;i++)
			{
				if(arr[i][4]==1 && can[i])
				{
					ans=false;
					break;
				}
			}
			if(ans)
				out.println("NO");
			else
				out.println("YES");
			//-------------------------------------
			out.close();
		}

		static class Pair implements Comparable<Pair> {
			int a, b;

			Pair(int a, int b) {
				this.a = a;
				this.b = b;
			}

			public int compareTo(Pair o) {
				// TODO Auto-generated method stub
				if (this.a != o.a)
					return Integer.compare(this.a, o.a);
				else
					return Integer.compare(this.b, o.b);
				//return 0;
			}

			public boolean equals(Object o) {
				if (o instanceof Pair) {
					Pair p = (Pair) o;
					return p.a == a && p.b == b;
				}
				return false;
			}

			public int hashCode() {
				return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
			}

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

		static int[] sieve(int n,int[] arr)
		{
			for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==0)
				{
					for(int j=i*2;j<=n;j+=i)
						arr[j]=1;
				}
			}
			return arr;
		}

		static boolean isPal(String s)
		{
			for(int i=0, j=s.length()-1;i<=j;i++,j--)
			{
				if(s.charAt(i)!=s.charAt(j)) return false;
			}
			return true;
		}
		public static String rev(String s)
		{
			StringBuilder sb=new StringBuilder(s);
			sb.reverse();
			return sb.toString();
		}

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

		static long gcd(long a, long b)
		{
		    while (b > 0)
		    {
		        long temp = b;
		        b = a % b; // % is remainder
		        a = temp;
		    }
		    return a;
		}
		static long modulo(long a,long b,long c) {
			long x=1;
			long y=a;
			while(b > 0){
				if(b%2 == 1){
					x=(x*y)%c;
				}
				y = (y*y)%c; // squaring the base
				b /= 2;
			}
			return  x%c;
		}
		public static void debug(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}

		static long sort(int a[]) {
			int n = a.length;
			int b[] = new int[n];
			return mergeSort(a, b, 0, n - 1);
		}

		static long mergeSort(int a[], int b[], long left, long right) {
			long c = 0;
			if (left < right) {
				long mid = left + (right - left) / 2;
				c = mergeSort(a, b, left, mid);
				c += mergeSort(a, b, mid + 1, right);
				c += merge(a, b, left, mid + 1, right);
			}
			return c;
		}

		static long merge(int a[], int b[], long left, long mid, long right) {
			long c = 0;
			int i = (int) left;
			int j = (int) mid;
			int k = (int) left;
			while (i <= (int) mid - 1 && j <= (int) right) {
				if (a[i] <= a[j]) {
					b[k++] = a[i++];
				} else {
					b[k++] = a[j++];
					c += mid - i;
				}
			}
			while (i <= (int) mid - 1)
				b[k++] = a[i++];
			while (j <= (int) right)
				b[k++] = a[j++];
			for (i = (int) left; i <= (int) right; i++)
				a[i] = b[i];
			return c;
		}

		static final class InputReader{
			private final InputStream stream;
			private final byte[] buf=new byte[1024];
			private int curChar;
			private int numChars;
			public InputReader(InputStream stream){this.stream=stream;}
			private int read()throws IOException{
				if(curChar>=numChars){
					curChar=0;
					numChars=stream.read(buf);
					if(numChars<=0)
						return -1;
				}
				return buf[curChar++];
			}
			public final int nextInt()throws IOException{return (int)nextLong();}
			public final long nextLong()throws IOException{
				int c=read();
				while(isSpaceChar(c)){
					c=read();
					if(c==-1) throw new IOException();
				}
				boolean negative=false;
				if(c=='-'){
					negative=true;
					c=read();
				}
				long res=0;
				do{
					if(c<'0'||c>'9')throw new InputMismatchException();
					res*=10;
					res+=(c-'0');
					c=read();
				}while(!isSpaceChar(c));
				return negative?(-res):(res);
			}
			public final int[] readIntBrray(int size)throws IOException{
				int[] arr=new int[size];
				for(int i=0;i<size;i++)arr[i]=nextInt();
				return arr;
			}
			public final String next()throws IOException{
				int c=read();
				while(isSpaceChar(c))c=read();
				StringBuilder res=new StringBuilder();
				do{
					res.append((char)c);
					c=read();
				}while(!isSpaceChar(c));
				return res.toString();
			}
			public final String nextLine()throws IOException{
				int c=read();
				while(isSpaceChar(c))c=read();
				StringBuilder res=new StringBuilder();
				do{
					res.append((char)c);
					c=read();
				}while(c!='\n'&&c!=-1);
				return res.toString();
			}
			private boolean isSpaceChar(int c){
				return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
			}
		}
	}

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream("sum.in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream("sum.out");

//        Path path = Paths.get(URI.create("file:///foo/bar/Main.java"));
//        System.out.print(path.getName(200));

//        Path p = Paths.get("/foo/bar/Main.java");
//        for (Path e : p) {
//            System.out.println(e);
//        }

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private final int INF = (int) (1e9 + 7);

    public void solve(InputReader in, PrintWriter out) throws IOException {
        int[] l = new int[5];
        int[] s = new int[5];
        int[] r = new int[5];
        int[] p = new int[5];
        for (int i = 1; i <= 4; i++) {
            l[i] = in.nextInt();
            s[i] = in.nextInt();
            r[i] = in.nextInt();
            p[i] = in.nextInt();
        }

        boolean fl = false;

        for (int i = 1; i <= 4; i++) {
            if (p[i] == 1) {
                if (l[i] +  r[i] + s[i] != 0) {
                    fl = true;
                }
            }
        }

        if (l[1] == 1 && p[4] == 1 || r[1] == 1 && p[2] == 1 || s[1] == 1 && p[3] == 1) {
            fl = true;
        }
        if (l[2] == 1 && p[1] == 1 || r[2] == 1 && p[3] == 1 || s[2] == 1 && p[4] == 1) {
            fl = true;
        }
        if (l[3] == 1 && p[2] == 1 || r[3] == 1 && p[4] == 1 || s[3] == 1 && p[1] == 1) {
            fl = true;
        }
        if (l[4] == 1 && p[3] == 1 || r[4] == 1 && p[1] == 1 || s[4] == 1 && p[2] == 1) {
            fl = true;
        }

        if (fl) {
            out.print("YES");
        } else {
            out.print("NO");
        }
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

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

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Main {
    static FastScanner in;
    static PrintWriter out;
    static final int MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        //        Scanner in = new Scanner(new File("input.txt"));
        //        Scanner in = new Scanner(System.in);
        //        System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.txt")), true));
        out = new PrintWriter(System.out);
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int a0[] = new int[4];
        int a1[] = new int[4];
        int a2[] = new int[4];
        int a3[] = new int[4];
        for (int i = 0; i < 4; i++) {
            a0[i] = in.nextInt();
        }
        for (int i = 0; i < 4; i++) {
            a1[i] = in.nextInt();
        }
        for (int i = 0; i < 4; i++) {
            a2[i] = in.nextInt();
        }
        for (int i = 0; i < 4; i++) {
            a3[i] = in.nextInt();
        }
        boolean bb0 = a0[3] == 1 && (a0[0] == 1 || a0[1] == 1 || a0[2] == 1 || a2[1] == 1 || a1[0] == 1 || a3[2] == 1);
        boolean bb1 = a1[3] == 1 && (a1[0] == 1 || a1[1] == 1 || a1[2] == 1 || a3[1] == 1 || a2[0] == 1 || a0[2] == 1);
        boolean bb2 = a2[3] == 1 && (a2[0] == 1 || a2[1] == 1 || a2[2] == 1 || a0[1] == 1 || a3[0] == 1 || a1[2] == 1);
        boolean bb3 = a3[3] == 1 && (a3[0] == 1 || a3[1] == 1 || a3[2] == 1 || a1[1] == 1 || a0[0] == 1 || a2[2] == 1);
        if (bb0 || bb1 || bb2 || bb3)
            out.println("YES");
        else
            out.println("NO");
        out.close();
    }
}

class Pair {
    public int first; //first member of pair
    public int second; //second member of pair

    public Pair(int first, int second) {
        this.first = first;
        this.second = second;
    }

    public Pair() {

    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}

import java.util.Scanner;

public class A811 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		long m = s.nextLong();
		long n = s.nextLong();
		long d=1;
		boolean turn =true;
		boolean mlose=false;
		while(true){
			if(turn){
				turn=false;
				m-=d;
				//System.out.println("m " +m);
				if(m<0){
					System.out.println("Vladik");
					break;
				}

			}else{
				turn = true;
				n-=d;

//				System.out.println("n " +n);
				if(n<0){
					System.out.println("Valera");
					break;
				}
			}
			d++;
		}

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.abs;

public class A {

    static int left = 0;
    static int straight = 1;
    static int right = 2;
    static int pedestrian = 3;

    public static void main(String[] args) {

        MyScanner in = new MyScanner();
        boolean[][] a = new boolean[4][4];

        for(int i=0;i<4;++i){
            for(int j=0;j<4;++j){
                a[i][j] = in.nextInt() == 1;
            }
        }

        for(int i=0;i<4;++i){
            if(a[i][pedestrian]){
                int next = (i+1) % 4;
                int prev = (i+3) % 4;
                int opp = (i+2) %4;
                if(a[i][straight]||a[next][left]||a[prev][right]||a[opp][straight]){
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");

    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    // --------------------------------------------------------

}

import java.util.*;

public class CodeForces {

    public static void main(String[] args) {

      boolean q=false;
      int a []=new int [4];
      int b []=new int [4];
      int c []=new int [4];
      int d []=new int [4];
       int k=0;
       Scanner sc=new Scanner(System.in);
      for (int i=0;i<4;i++){
          a[i]=sc.nextInt();
         if (a[i]==1)k++;
      }
      if(a[3]==1&& k>1)q=true;
      k=0;
      for (int i=0;i<4;i++){
         b[i]=sc.nextInt();
         if (b[i]==1)k++;
      }
      if(b[3]==1&&k>1)q=true;
      k=0;

    for (int i=0;i<4;i++){
         c[i]=sc.nextInt();
         if (c[i]==1)k++;
      }
    if(c[3]==1&&k>1)q=true;
      k=0;

      for (int i=0;i<4 ;i++){
          if (d[i]==1)k++;
         d[i]=sc.nextInt();
      }
      if(k>1)q=true;
      k=0;
      if(q==true){
          System.out.println("Yes");
          return;
      }
      else{
          if(a[3]==1){
              if(b[0]==1||c[1]==1||d[2]==1)q=true;
          }
         else if(b[3]==1){
              if(c[0]==1||d[1]==1||a[2]==1)q=true;
          }
        else if(c[3]==1){
              if(d[0]==1||a[1]==1||b[2]==1)q=true;
          }
         else if(d[3]==1){
              if(a[0]==1||b[1]==1||c[2]==1)q=true;
          }
      }
      if (q==true)System.out.println("Yes");
      else System.out.println("No");

          }
}

import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[][] a = new int[4][4];
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                a[i][j] = in.nextInt();
            }
        }
        boolean check = true;
        for (int i = 0; i < 4 && check; i++) {
            for (int j = 0; j < 3 && check; j++) {
                if ((a[i][j] > 0 || a[i][(i + 1) % 4] > 0) && (a[i][3] > 0)) {
                    System.out.println("Yes");
                    check = false;
                }
            }
        }
        if (check) {
            System.out.println("No");
        }

        in.close();
    }
}

import java.util.*;

import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        boolean[][] b = new boolean[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                b[i][j] = in.nextInt() == 1;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (b[i][3] && (b[i][0] || b[i][1] || b[i][2])) {
                System.out.println("YES");
                return;
            }
            if (b[0][i] && b[3][((i - 1) + 4) % 4]) {
                System.out.println("YES");
                return;
            }
            if (b[1][i] && b[3][((i - 2) + 4) % 4]) {
                System.out.println("YES");
                return;
            }
            if (b[2][i] && b[3][((i + 1) + 4) % 4]) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}

import java.util.*;
public class Crossroads {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[][] arr = new int[4][4];
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				arr[i][j] = scan.nextInt();
			}
		}
		for(int i=0;i<4;i++){
			if(arr[i][3] == 1){
				for(int j=0;j<4;j++){
					if(arr[i][j] == 1) {
					if(j==0){
						int k = i;
						k = (k - 1)%4;
						if(k==-1){
							k=3;
						}
						if(arr[k][3]==1){
							System.out.println("YES");
							return;
						}
					}
					else if(j==1){
						int k = i;
						k = (k + 2) % 4;
						if(arr[k][3]==1){
							System.out.println("YES");
							return;
						}
					}
					else if(j==2){
						int k = i;
						k = (k + 1) % 4;
						if(arr[k][3]==1){
							System.out.println("YES");
							return;
						}
					}
				}
				}
			}
		}
		System.out.println("NO");
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.acl.LastOwnerException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class SagheerTheHausmeister {
	public static int n,m,lastLights;
	public static int building[][];
	public static int firstFromLeft[],firstFromRight[];
	public static int dp[][];
	public static boolean hasLights[];
	public static int closeTheLights(int floor,int isOnLeft)
	{
		if (floor >= n)
			return 0;
		if (dp[floor][isOnLeft]!=-1)
			return dp[floor][isOnLeft];
		int x = closeTheLights(floor+1, 1);
		int y = closeTheLights(floor+1, 0);
		int a,b;
		//On the right
		if (isOnLeft==0)
		{
			if (x==0)
				return dp[floor][isOnLeft]=(m + 1 - firstFromLeft[floor]);
			a = m + 1 + x;
			b = (m + 1 - firstFromLeft[floor])*2 + y;
			System.out.println(floor+" "+isOnLeft+" "+a+" "+b);
			return dp[floor][isOnLeft]=Math.min(a,b)+1;
		}
		//On the left
		if (x==0)
			return dp[floor][isOnLeft]=firstFromRight[floor];
		a = m + 1 + y;
		b = firstFromRight[floor]*2 + x;
		return dp[floor][isOnLeft]=Math.min(a, b)+1;
	}
	public static void main(String args[]) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		firstFromLeft = new int[n];
		firstFromRight = new int[n];
		building = new int[n][m+2];
		dp = new int [n][2];
		hasLights = new boolean[n];
		int lastLight = -1;
		for (int i=n-1;i>=0;i--)
		{
			Arrays.fill(dp[i], -1);
			String s = sc.nextLine();
			for (int j=0;j<m+2;j++)
			{
				building[i][j] = s.charAt(j)-'0';
				if (building[i][j]==1)
				{
					hasLights[i] = true;
					if (lastLight==-1)
						lastLight=i;
				}
				if (firstFromLeft[i]==0 && building[i][j]==1)
					firstFromLeft[i] = j;
				if (building[i][j] == 1)
					firstFromRight[i] = j;
			}
			if (firstFromLeft[i]==0)
				firstFromLeft[i]=m+1;
		}
		System.out.println(closeTheLights(0, 1));
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

	}
}

import java.io.*;
import java.util.*;

public class SagheerAndCrossroads {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean[] car = new boolean[4];
		for(int i = 0; i<4; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int l = Integer.parseInt(st.nextToken());
			int s = Integer.parseInt(st.nextToken());
			int r = Integer.parseInt(st.nextToken());
			int p = Integer.parseInt(st.nextToken());
			boolean f = (l+s+r)>0;
			if(p==1 && f) {
				System.out.println("YES");
				return;
			}

			if(l==1) {
				if(i==0) {
					if(car[3]) {
						System.out.println("YES");
						return;
					}
					car[3] = true;
				}else {
					if(car[i-1]) {
						System.out.println("YES");
						return;
					}
					car[i-1] = true;
				}
			}else if(s==1) {
				if(car[(i+2)%4]) {
					System.out.println("YES");
					return;
				}
				car[(i+2)%4] = true;
			}else if(r==1) {
				if(i==3) {
					if(car[0]) {
						System.out.println("YES");
						return;
					}
					car[0] = true;
				}else {
					if(car[i+1]) {
						System.out.println("YES");
						return;
					}
					car[i+1] = true;
				}
			}

			if(p==1) {
				if(car[i]) {
					System.out.println("YES");
					return;
				}else {
					car[i] = true;
				}
			}
		}
		System.out.println("NO");
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class pola {

	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st = new StringTokenizer(br.readLine());
	//	int n = Integer.parseInt(st.nextToken());
		int [][]Arr=new int [4][4];
		for(int i=0;i<4;i++){
			StringTokenizer st = new StringTokenizer(br.readLine());
		for(int j=0;j<4;j++)
			Arr[i][j]= Integer.parseInt(st.nextToken());
		}
		if(Arr[0][3]==1){
			if(Arr[0][0]==1||Arr[0][1]==1||Arr[0][2]==1||Arr[2][1]==1){
				System.out.println("YES");return;
			}

		}
		if(Arr[1][3]==1){
			if(Arr[1][0]==1||Arr[1][1]==1||Arr[1][2]==1||Arr[3][1]==1){
				System.out.println("YES");return;
			}

		}
		if(Arr[2][3]==1){
			if(Arr[2][0]==1||Arr[2][1]==1||Arr[2][2]==1||Arr[0][1]==1){
				System.out.println("YES");return;
			}

		}
		if(Arr[3][3]==1){
			if(Arr[3][0]==1||Arr[3][1]==1||Arr[3][2]==1||Arr[1][1]==1){
				System.out.println("YES");return;
			}

		}
		System.out.println("NO");

	}

}

import java.util.*;
import java.io.*;
public class SagheerAndCrossroads {
	public static void main(String[]args) throws IOException{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		boolean accident = false;
		int cross[][] = new int[4][4];
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<4;j++)
			{
				cross[i][j]=sc.nextInt();
				if(cross[i][3]==1)
				{
					if(cross[i][j]==1 && j!=3)
					{
						accident = true;
						break;
					}
				}
			}
		}
		if(cross[0][3]==1)
		{
			if(cross[1][0]==1 || cross[2][1]==1 || cross[3][2]==1)
			{
				accident = true;
			}
		}
		if(cross[1][3]==1)
		{
			if(cross[0][2]==1 || cross[2][0]==1 || cross[3][1]==1)
			{
				accident =true;
			}
		}
		if(cross[2][3]==1)
		{
			if(cross[0][1]==1 || cross[1][2]==1 || cross[3][2]==1)
			{
				accident =true;
			}
		}
		if(cross[3][3]==1)
		{
			if(cross[0][0] ==1|| cross[1][1]==1 || cross[2][2]==1)
			{
				accident =true;
			}
		}
		if(accident)
			pw.print("YES");
		else
			pw.print("NO");
		pw.flush();
		pw.close();
	}
}
class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

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

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

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A_ {
	public static void main(String[]args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		int [] l= new int[4];
		int [] s= new int[4];
		int [] r= new int[4];
		int [] p= new int[4];
		boolean flag= false;
		for(int i=0; i< 4; i++){
			l[i]= scanner.nextInt();
			s[i]= scanner.nextInt();
			r[i]= scanner.nextInt();
			p[i]= scanner.nextInt();
		}
		if(p[0]==1){
			if(l[0]==1 || s[0] ==1 || r[0] ==1 || l[1]==1 || s[2]==1 || r[3]==1 ){
				System.out.println("YES");
				flag= true;
			}

		}
		else if(p[1]==1){
			if(l[1]==1 || s[1] ==1 || r[1] ==1 || l[2]==1 || s[3]==1 || r[0]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		else if(p[2]==1){
			if(l[2]==1 || s[2] ==1 || r[2] ==1 || l[3]==1 || s[0]==1 || r[1]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		else if(p[3]==1){
			if(l[3]==1 || s[3] ==1 || r[3] ==1 || l[0]==1 || s[1]==1 || r[2]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		if(!flag)
			System.out.println("NO");

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

	}

}

import java.io.*;
import java.util.*;

public class Main {
	static int[][] road;
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;

		road = new int[4][4];
		for(int i=0;i<4;i++){
			st = new StringTokenizer(br.readLine());
			for(int j=0;j<4;j++){
				road[i][j] = Integer.parseInt(st.nextToken());
			}
		}
		boolean acc = false;
		if(road[0][0]==1 && road[3][3]==1)
			acc = true;
		if(road[0][1]==1 &&  ( road[2][3]==1 || road[0][3]==1))
			acc = true;
		if(road[0][2]==1 && ( road[1][3]==1 || road[0][3]==1))
			acc = true;

		if(road[1][0]==1 && road[0][3]==1)
			acc = true;
		if(road[1][1]==1 && ( road[3][3]==1 || road[1][3]==1))
			acc = true;
		if(road[1][2]==1 && ( road[2][3]==1 || road[1][3]==1))
			acc = true;

		if(road[2][0]==1 && road[1][3]==1)
			acc = true;
		if(road[2][1]==1 && ( road[0][3]==1 || road[2][3]==1))
			acc = true;
		if(road[2][2]==1 && ( road[3][3]==1 || road[2][3]==1))
			acc = true;

		if(road[3][0]==1 && road[2][3]==1)
			acc = true;
		if(road[3][1]==1 && ( road[1][3]==1 || road[3][3]==1))
			acc = true;
		if(road[3][2]==1 && ( road[0][3]==1 || road[3][3]==1))
			acc = true;

		if(acc)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String result = "NO";
        Scanner sc = new Scanner(System.in);
        boolean [][] arr= new boolean[4][4];
        for(int i = 0; i < 4; i++) {
            String [] s = sc.nextLine().split(" ");

            for(int j = 0;j < s.length; j++) {
                if(s[j].equals("0")) {
                    arr[i][j] = false;
                } else {

                    arr[i][j] = true;
                }
            }

        }

        for(int i = 0; i < 4; i++) {
            if(arr[i][3] == true) {
                if(arr[i][0] == true || arr[i][1] == true ||  arr[i][2] == true) {
                    result = "YES";
                    break;
                }
                int tmp;
                if(i == 2) tmp = 0; else if(i == 3) tmp = 1; else tmp = i +2;
                if(arr[i][1] == true && arr[tmp][3] == true) {
                    result = "YES";
                    break;
                }

                if(i == 0) tmp = 3 ; else tmp = i -1;
                if(arr[i][0] == true && arr[tmp][3] == true) {
                    result = "YES";
                    break;
                }
            }

        }

        System.out.println(result);

    }
        }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Solution implements Runnable
{
    private void solve() throws IOException
    {
        //int n = nextInt();

        int[][] array = new int[4][4];

        for (int i = 0; i < 4; i++) {
            boolean hasOne = false;
            for (int j = 0; j < 4; j++) {
                int x = nextInt();
                if (x == 1 && hasOne) {
                    writer.print("YES");
                    return;
                }
                array[i][j] = x;
            }
        }

        int p1 = array[0][3], p2 = array[1][3], p3 = array[2][3], p4 = array[3][3];

        if (p1 == 1 && (array[1][0] == 1 || array[2][1] == 1 || array[2][2] == 1)) {
            writer.print("YES");
            return;
        }
        if (p2 == 1 && (array[0][2] == 1 || array[2][0] == 1 || array[2][1] == 1)) {
            writer.print("YES");
            return;
        }
        if (p3 == 1 && (array[0][1] == 1 || array[1][2] == 1 || array[2][0] == 1)) {
            writer.print("YES");
            return;
        }
        if (p4 == 1 && (array[0][0] == 1 || array[1][1] == 1 || array[2][2] == 1)) {
            writer.print("YES");
            return;
        }

        writer.print("NO");

    }

    private Long sumDiagLR (Long[][] array) {
        long sum = 0;
        int i = 0, j = 0;

        while (i < array.length && j < array.length) {
            sum += array[i][j];
            i++;
            j++;
        }

        return sum;
    }

    private Long sumDiagRL (Long[][] array) {
       long sum = 0;
       int i = array.length-1, j = 0;

       while (i >=0 && j < array.length) {
           sum += array[i][j];
           i--;
           j++;
       }

       return sum;
   }

    private BigInteger factorial( String n )
    {
        BigInteger k = new BigInteger( n );
        BigInteger ans = BigInteger.ONE;

        while ( k.compareTo( BigInteger.ONE ) > 0 )
        {
            ans = ans.multiply( k );
            k = k.subtract( BigInteger.ONE );
        }

        return ans;
    }

    private long combinations( int n, int r )
    {
        return ( factorial( String.valueOf( n ) ).divide( ( new BigInteger( String.valueOf( r ) ).multiply( factorial( String.valueOf( n - r ) ) ) ) ) ).longValue();
    }

    private String binaryXOR( String s1, String s2 )
    {
        BigInteger a = new BigInteger( s1, 2 );
        BigInteger b = new BigInteger( s2, 2 );

        return a.xor( b ).toString( 2 );

    }

    private static void findDP( Node node )
    {
        for ( Node child : node.children )
        {
            if ( child.value > node.value )
            {
                child.dp = Math.max( child.dp, node.dp + 1 );
                //findDP( child );
            }
        }
    }

    private static class Obj implements Comparable<Obj>
    {
        String name;
        int value;

        public Obj( int value )
        {
            this.value = value;
        }

        public Obj( String name, int value )
        {
            this.name = name;
            this.value = value;
        }

        @Override
        public int compareTo( Obj o )
        {
            return o.value - this.value;
        }
    }

    private static class Edge
    {
        PNode src;
        PNode des;
        long cost;

        public Edge (PNode src, PNode des, long cost) {
            this.src = src;
            this.des = des;
            this.cost = cost;
        }
    }

    private static class PNode
    {
        List<Edge> edges;
        long value;
        boolean isTrue;

        public PNode() {
            this.edges = new ArrayList<>(  );
            this.isTrue = false;
        }

        public PNode(long value ) {
           this.edges = new ArrayList<>(  );
           this.isTrue = false;
            this.value = value;
       }
    }

    private static class Node
    {
        long value;
        long dp;
        List<Node> children;
        Node parent;

        public  Node(){};

        public Node( int value )
        {
            this.value = value;
            dp = 1;
            children = new ArrayList<Node>();
        }
    }

    private static boolean isInt( String s )
    {
        if ( s.length() < 1 )
            return false;
        else
        {
            for ( char c : s.toCharArray() )
            {
                if ( c < '0' || c > '9' )
                {
                    return false;
                }
            }
        }

        return true;
    }

    private static Map<String, Integer> findSubString( String s, int k )
    {
        Map<String, Integer> map = new HashMap<>();
        for ( int i = 0; i < s.length() - ( k - 1 ); i++ )
        {
            String str = new String( s.substring( i, i + k ) );
            if ( map.containsKey( str ) )
            {
                map.put( str, map.get( str ) + 1 );
            }
            else
            {
                map.put( str, 1 );

            }
        }

        return map;
    }

    //mergesort

    public static Comparable[] mergeSort( Comparable[] list )
    {
        if ( list.length <= 1 )
        {
            return list;
        }

        Comparable[] left = new Comparable[ list.length / 2 ];
        Comparable[] right = new Comparable[ list.length - left.length ];
        System.arraycopy( list, 0, left, 0, left.length );
        System.arraycopy( list, left.length, right, 0, right.length );

        mergeSort( left );
        mergeSort( right );

        merge( left, right, list );
        return list;
    }

    private static void merge( Comparable[] left, Comparable[] right, Comparable[] result )
    {
        int leftIdx = 0;
        int rightIdx = 0;
        int index = 0;

        while ( leftIdx < left.length && rightIdx < right.length )
        {
            if ( left[ leftIdx ].compareTo( right[ rightIdx ] ) < 0 )
            {
                result[ index++ ] = left[ leftIdx ];
                leftIdx++;
            }
            else
            {
                result[ index++ ] = right[ rightIdx ];
                rightIdx++;
            }
        }

        System.arraycopy( left, leftIdx, result, index, left.length - leftIdx );
        System.arraycopy( right, rightIdx, result, index, right.length - rightIdx );
    }

    public static List<Obj> mergeSort( List<Obj> list )
    {
        if ( list.size() <= 1 )
        {
            return list;
        }

        List<Obj> left = new ArrayList( list.subList( 0, list.size() / 2 ) );
        List<Obj> right = new ArrayList( list.subList( left.size(), list.size() ) );

        left = mergeSort( left );
        right = mergeSort( right );

        list = merge( left, right );

        return list;
    }

    private static List<Obj> merge( List<Obj> left, List<Obj> right )
    {
        int leftCounter = 0, rightCounter = 0;
        List<Obj> result = new ArrayList<>();

        while ( leftCounter < left.size() && rightCounter < right.size() )
        {
            Obj leftItem = left.get( leftCounter );
            Obj rightItem = right.get( rightCounter );

            if ( leftItem.compareTo( rightItem ) < 0 )
            {
                result.add( leftItem );
                leftCounter++;
            }
            else
            {
                result.add( rightItem );
                rightCounter++;
            }
        }

        if ( leftCounter >= left.size() )
            result.addAll( right.subList( rightCounter, right.size() ) );
        else if ( rightCounter >= right.size() )
            result.addAll( left.subList( leftCounter, left.size() ) );

        return result;
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run()
    {
        try
        {
            reader = new BufferedReader( new InputStreamReader( System.in ) );
            tokenizer = null;
            writer = new PrintWriter( System.out );
            solve();
            reader.close();
            writer.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();
    }

    // Arrays.sort(array, Comparator.comparing((int[] arr) -> arr[1]));
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Solution implements Runnable
{
    private void solve() throws IOException
    {
        //int n = nextInt();

        int[][] array = new int[4][4];

        for (int i = 0; i < 4; i++) {
            boolean hasOne = false;
            for (int j = 0; j < 4; j++) {
                int x = nextInt();
                if (x == 1 && hasOne) {
                    writer.print("YES");
                    return;
                }
                array[i][j] = x;
            }
        }

        int p1 = array[0][3], p2 = array[1][3], p3 = array[2][3], p4 = array[3][3];

        if (p1 == 1 && (array[1][0] == 1 || array[2][1] == 1 || array[2][2] == 1)) {
            writer.print("YES");
            return;
        }
        if (p2 == 1 && (array[0][2] == 1 || array[2][0] == 1 || array[2][1] == 1)) {
            writer.print("YES");
            return;
        }
        if (p3 == 1 && (array[0][1] == 1 || array[1][2] == 1 || array[3][0] == 1)) {
            writer.print("YES");
            return;
        }
        if (p4 == 1 && (array[0][0] == 1 || array[1][1] == 1 || array[2][2] == 1)) {
            writer.print("YES");
            return;
        }

        writer.print("NO");

    }

    private Long sumDiagLR (Long[][] array) {
        long sum = 0;
        int i = 0, j = 0;

        while (i < array.length && j < array.length) {
            sum += array[i][j];
            i++;
            j++;
        }

        return sum;
    }

    private Long sumDiagRL (Long[][] array) {
       long sum = 0;
       int i = array.length-1, j = 0;

       while (i >=0 && j < array.length) {
           sum += array[i][j];
           i--;
           j++;
       }

       return sum;
   }

    private BigInteger factorial( String n )
    {
        BigInteger k = new BigInteger( n );
        BigInteger ans = BigInteger.ONE;

        while ( k.compareTo( BigInteger.ONE ) > 0 )
        {
            ans = ans.multiply( k );
            k = k.subtract( BigInteger.ONE );
        }

        return ans;
    }

    private long combinations( int n, int r )
    {
        return ( factorial( String.valueOf( n ) ).divide( ( new BigInteger( String.valueOf( r ) ).multiply( factorial( String.valueOf( n - r ) ) ) ) ) ).longValue();
    }

    private String binaryXOR( String s1, String s2 )
    {
        BigInteger a = new BigInteger( s1, 2 );
        BigInteger b = new BigInteger( s2, 2 );

        return a.xor( b ).toString( 2 );

    }

    private static void findDP( Node node )
    {
        for ( Node child : node.children )
        {
            if ( child.value > node.value )
            {
                child.dp = Math.max( child.dp, node.dp + 1 );
                //findDP( child );
            }
        }
    }

    private static class Obj implements Comparable<Obj>
    {
        String name;
        int value;

        public Obj( int value )
        {
            this.value = value;
        }

        public Obj( String name, int value )
        {
            this.name = name;
            this.value = value;
        }

        @Override
        public int compareTo( Obj o )
        {
            return o.value - this.value;
        }
    }

    private static class Edge
    {
        PNode src;
        PNode des;
        long cost;

        public Edge (PNode src, PNode des, long cost) {
            this.src = src;
            this.des = des;
            this.cost = cost;
        }
    }

    private static class PNode
    {
        List<Edge> edges;
        long value;
        boolean isTrue;

        public PNode() {
            this.edges = new ArrayList<>(  );
            this.isTrue = false;
        }

        public PNode(long value ) {
           this.edges = new ArrayList<>(  );
           this.isTrue = false;
            this.value = value;
       }
    }

    private static class Node
    {
        long value;
        long dp;
        List<Node> children;
        Node parent;

        public  Node(){};

        public Node( int value )
        {
            this.value = value;
            dp = 1;
            children = new ArrayList<Node>();
        }
    }

    private static boolean isInt( String s )
    {
        if ( s.length() < 1 )
            return false;
        else
        {
            for ( char c : s.toCharArray() )
            {
                if ( c < '0' || c > '9' )
                {
                    return false;
                }
            }
        }

        return true;
    }

    private static Map<String, Integer> findSubString( String s, int k )
    {
        Map<String, Integer> map = new HashMap<>();
        for ( int i = 0; i < s.length() - ( k - 1 ); i++ )
        {
            String str = new String( s.substring( i, i + k ) );
            if ( map.containsKey( str ) )
            {
                map.put( str, map.get( str ) + 1 );
            }
            else
            {
                map.put( str, 1 );

            }
        }

        return map;
    }

    //mergesort

    public static Comparable[] mergeSort( Comparable[] list )
    {
        if ( list.length <= 1 )
        {
            return list;
        }

        Comparable[] left = new Comparable[ list.length / 2 ];
        Comparable[] right = new Comparable[ list.length - left.length ];
        System.arraycopy( list, 0, left, 0, left.length );
        System.arraycopy( list, left.length, right, 0, right.length );

        mergeSort( left );
        mergeSort( right );

        merge( left, right, list );
        return list;
    }

    private static void merge( Comparable[] left, Comparable[] right, Comparable[] result )
    {
        int leftIdx = 0;
        int rightIdx = 0;
        int index = 0;

        while ( leftIdx < left.length && rightIdx < right.length )
        {
            if ( left[ leftIdx ].compareTo( right[ rightIdx ] ) < 0 )
            {
                result[ index++ ] = left[ leftIdx ];
                leftIdx++;
            }
            else
            {
                result[ index++ ] = right[ rightIdx ];
                rightIdx++;
            }
        }

        System.arraycopy( left, leftIdx, result, index, left.length - leftIdx );
        System.arraycopy( right, rightIdx, result, index, right.length - rightIdx );
    }

    public static List<Obj> mergeSort( List<Obj> list )
    {
        if ( list.size() <= 1 )
        {
            return list;
        }

        List<Obj> left = new ArrayList( list.subList( 0, list.size() / 2 ) );
        List<Obj> right = new ArrayList( list.subList( left.size(), list.size() ) );

        left = mergeSort( left );
        right = mergeSort( right );

        list = merge( left, right );

        return list;
    }

    private static List<Obj> merge( List<Obj> left, List<Obj> right )
    {
        int leftCounter = 0, rightCounter = 0;
        List<Obj> result = new ArrayList<>();

        while ( leftCounter < left.size() && rightCounter < right.size() )
        {
            Obj leftItem = left.get( leftCounter );
            Obj rightItem = right.get( rightCounter );

            if ( leftItem.compareTo( rightItem ) < 0 )
            {
                result.add( leftItem );
                leftCounter++;
            }
            else
            {
                result.add( rightItem );
                rightCounter++;
            }
        }

        if ( leftCounter >= left.size() )
            result.addAll( right.subList( rightCounter, right.size() ) );
        else if ( rightCounter >= right.size() )
            result.addAll( left.subList( leftCounter, left.size() ) );

        return result;
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run()
    {
        try
        {
            reader = new BufferedReader( new InputStreamReader( System.in ) );
            tokenizer = null;
            writer = new PrintWriter( System.out );
            solve();
            reader.close();
            writer.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();
    }

    // Arrays.sort(array, Comparator.comparing((int[] arr) -> arr[1]));
}

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int arr[][] = new int[4][4];
			for (int i = 0; i < arr.length; i++) {
				for (int j = 0; j < arr.length; j++) {
					arr[j][i] = sc.nextInt();
				}
			}

			int sum = 0;
			for (int i = 0; i < 4; i++) {
				if (arr[3][i] == 1) {
					if (arr[2][Math.abs((i - 1) % 4)] == 1) {
						sum++;

					}
					if (arr[0][(i+1)%4]==1) {
						sum++;
					}
					if (arr[1][(i + 2) % 4] == 1) {
						sum++;
					}
				}
			}
			if (sum > 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

	}
}

import java.io.*;
import java.util.*;

public class SagheerAndCrossroads {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean[] car = new boolean[4];
		for(int i = 0; i<4; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int l = Integer.parseInt(st.nextToken());
			int s = Integer.parseInt(st.nextToken());
			int r = Integer.parseInt(st.nextToken());
			int p = Integer.parseInt(st.nextToken());
			boolean f = (l+s+r)>0;
			if(p==1 && f) {
				System.out.println("YES");
				return;
			}

			if(l==1) {
				if(i==0) {
					car[3] = true;
				}else {
					car[i-1] = true;
				}
			}else if(s==1) {
				car[(i+2)%4] = true;
			}else if(r==1) {
				if(i==3) {
					car[0] = true;
				}else {
					car[i+1] = true;
				}
			}

			if(p==1 && car[i]) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}

/**
 * Created by Администратор on 23.05.2017.
 */
import java.util.*;
import java.lang.*;
public class Main {
    public static void main(String[] argv)
    {
        Scanner sc = new Scanner(System.in);

        Integer[][] a = new Integer[4][4];

        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++)
                a[i][j] = sc.nextInt();

        boolean accident = false;

        for (int i = 0; i < 3; i++)
        {
            if (a[i][3] == 1)
            {
                for (int j = 0; j <= 2; j++)
                {
                    if (a[i][j] == 1) accident = true;
                }

                if (a[(i+1 > 3) ? i-3 : i+1][0] == 1) accident = true;
                if (a[(i+2 > 3) ? i-2 : i+2][1] == 1) accident = true;
                if (a[(i+3 > 3) ? i-1 : i+3][2] == 1) accident = true;
            }
        }

        System.out.print(accident ? "YES" : "NO");

    }
}

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

public class CF812A {
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int l = 0;
		int r = 1;
		int s = 2;
		int[][] ar = {
				{3,2,1},
				{0,3,2},
				{1,0,3},
				{2,1,0}
		};
		int[][] in = new int[4][4];
		for(int i = 0;i<4;i++)
			for(int j=0;j<4;j++)
				in[i][j] = fr.nextInt();
		//sovle
		boolean ans = true;
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(in[i][j]==1&&in[i][3]==1)
				{
					System.out.println("YES");
					return;
				}
			}
		}
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(in[i][j]==1&&in[ar[i][j]][3]==1)
				{
					System.out.println("YES");
					return;
				}
			}
		}
		System.out.println("NO");
	}

	//Better IO Class
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		public Float nextFloat() {
			return Float.parseFloat(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
	}
}

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int arr[][] = new int[4][4];
			for (int i = 0; i < arr.length; i++) {
				for (int j = 0; j < arr.length; j++) {
					arr[j][i] = sc.nextInt();
				}
			}

			int sum = 0;
			for (int i = 0; i < 4; i++) {

				if (arr[3][i] == 1) {
					if (arr[2][Math.abs((i - 1) % 4)] == 1) {
						sum++;

					}
					if (arr[0][(i+1)%4]==1) {
						sum++;
					}
					if (arr[1][(i + 2) % 4] == 1) {
						sum++;
					}
				if(arr[0][i]==1){sum++;}
				}

			}
			if (sum > 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

	}
}

import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[][] a = new int[4][4];
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                a[i][j] = in.nextInt();
            }
        }
        boolean check = true;
        for (int i = 0; i < 4 && check; i++) {
            for (int j = 0; j < 3 && check; j++) {
                if ((a[i][j] > 0 || a[0][(i + 3) % 4] > 0 || a[1][(i + 2) % 4] > 0 || a[2][(i + 1) % 4] > 0) && (a[i][3] > 0)) {
                    System.out.println("Yes");
                    check = false;
                }
            }
        }
        if (check) {
            System.out.println("No");
        }

        in.close();
    }
}

import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[][] a = new int[4][4];
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                a[i][j] = in.nextInt();
            }
        }
        boolean check = true;
        for (int i = 0; i < 4 && check; i++) {
            for (int j = 0; j < 3 && check; j++) {
                if ((a[i][j] > 0 || a[(i + 3) % 4][2] > 0 || a[(i + 2) % 4][1] > 0 || a[(i + 1) % 4][1] > 0) && (a[i][3] > 0)) {
                    System.out.println("Yes");
                    check = false;
                }
            }
        }
        if (check) {
            System.out.println("No");
        }

        in.close();
    }
}

import java.io.*;
import java.util.*;

/*
TASK: CFA
LANG: JAVA
 */
public class CFA {
    static int[] l , s , r , p;

    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        l = new int[4];
        s = new int[4];
        r = new int[4];
        p = new int[4];
        for(int i = 0;i < 4; i++){
            l[i] = in.nextInt();
            s[i] = in.nextInt();
            r[i] = in.nextInt();
            p[i] = in.nextInt();
        }
        for(int i = 0;i < 4; i++){
            if(p[i]== 1){
                if(l[i] == 1 || s[i] == 1 || r[i] == 1 || l[(i+1)%4] == 1 || r[(i+3)%4] == 1){
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    private static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        boolean isEndline(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

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

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}

import java.util.*;
import java.io.*;

public class Solution{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        boolean[][] arr = new boolean[4][4];
        for(int i=0;i<4;++i){
            for(int j=0;j<4;++j){
                arr[i][j] = sc.nextByte()==0?false:true;
            }
        }
        boolean ans = false;
        for(int i=0;i<4;++i){
            if(arr[i][3]==false) continue;
            arr[i][3]=false;
            for(int j=0;j<4;++j){
                ans|=arr[i][j];
                ans|=arr[(i+j)%4][3-j];
            }
        }
        if(ans) System.out.print("YES");
        else System.out.print("NO");
        return;

    }
}

/**
 * Created by Ariana Herbst on 6/13/17.
 */

import java.util.*;
import java.io.*;

public class cfs417A {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        StringBuilder sb = new StringBuilder();
        boolean[] lights = new boolean[12];
        boolean[] ped = new boolean[4];
        boolean ans = false;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                lights[i*3 + j] = sc.nextInt() == 1;
            }
            ped[i] = sc.nextInt() == 1;
        }
        for (int i = 0; i < 12; i += 3) {
            if (ped[i/3]) {
                for (int j = i-1; j <= i + 3; j++) {
                    if (lights[(j+12)%12]) {
                        ans = true;
                    }
                }
            }
        }
        sb.append(ans ? "YES" : "NO");
        System.out.println(sb);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }

        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextLong();
            }
            return a;
        }
    }
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int ar[][] = new int[4][4];
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++)
				ar[i][j] = sc.nextInt();
		boolean ans = false;
		for (int i = 0; i < 4; i++) {
			if (ar[i][3] == 1) {
				if (ar[i][1] == 1) {
					ans = true;
					break;
				}
				if (ar[(i + 1) % 4][0] == 1 || ar[(i + 2) % 4][1] == 1 || ar[(i + 3) % 4][2] == 1) {
					ans = true;
					break;
				}

			}

		}
		if (ans == true) {
			System.out.println("YES");
		} else
			System.out.println("NO");
	}

}

import java.util.*;
public class Crossroads {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[][] arr = new int[4][4];
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				arr[i][j] = scan.nextInt();
			}
		}
		for(int i=0;i<4;i++){
			if(arr[i][3] == 1){
				for(int j=0;j<4;j++){
					if(arr[i][j] == 1) {
					if(j==0){
						int k = j;
						k = (j - 1)%4;
						if(k==-1){
							k=3;
						}
						if(arr[k][3]==1){
							System.out.println("YES");
							return;
						}
					}
					else if(j==1){
						int k = j;
						k = (k + 2) % 4;
						if(arr[k][3]==1){
							System.out.println("YES");
							return;
						}
					}
					else if(j==2){
						int k = j;
						k = (k + 1) % 4;
						if(arr[k][3]==1){
							System.out.println("YES");
							return;
						}
					}
				}
				}
			}
		}
		System.out.println("NO");
	}

}

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Main {
    static FastScanner in;
    static PrintWriter out;
    static final int MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        //        Scanner in = new Scanner(new File("input.txt"));
        //        Scanner in = new Scanner(System.in);
        //        System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.txt")), true));
        out = new PrintWriter(System.out);
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int a0[] = new int[4];
        int a1[] = new int[4];
        int a2[] = new int[4];
        int a3[] = new int[4];
        for (int i = 0; i < 4; i++) {
            a0[i] = in.nextInt();
        }
        for (int i = 0; i < 4; i++) {
            a1[i] = in.nextInt();
        }
        for (int i = 0; i < 4; i++) {
            a2[i] = in.nextInt();
        }
        for (int i = 0; i < 4; i++) {
            a3[i] = in.nextInt();
        }
        boolean bb0 = a0[3] == 1 && (a0[0] == 1 || a0[1] == 1 || a0[0] == 1);
        boolean bb1 = a1[3] == 1 && (a1[0] == 1 || a1[1] == 1 || a1[2] == 1);
        boolean bb2 = a2[3] == 1 && (a2[0] == 1 || a2[1] == 1 || a2[2] == 1);
        boolean bb3 = a3[3] == 1 && (a3[0] == 1 || a3[1] == 1 || a3[2] == 1);
        boolean b0 = (a0[0] == a3[3] && a3[3] == 1) || (a0[1] == a2[3] && a2[3] == 1) || (a0[2] == a1[3] && a1[3] == 1);
        boolean b1 = (a1[0] == a0[3] && a0[3] == 1) || (a1[1] == a3[3] && a3[3] == 1) || (a1[2] == a2[3] && a2[3] == 1);
        boolean b2 = (a2[0] == a1[3] && a1[3] == 1) || (a2[1] == a0[3] && a0[3] == 1) || (a2[2] == a3[3] && a3[3] == 1);
        boolean b3 = (a3[0] == a2[3] && a2[3] == 1) || (a3[1] == a1[3] && a1[3] == 1) || (a3[2] == a0[3] && a0[3] == 1);
        if (b1 || b2 || b3 || b0 || bb0 || bb1 || bb2 || bb3)
            out.println("YES");
        else
            out.println("NO");
        out.close();
    }
}

class Pair {
    public int first; //first member of pair
    public int second; //second member of pair

    public Pair(int first, int second) {
        this.first = first;
        this.second = second;
    }

    public Pair() {

    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}

import java.util.*;

//Mann Shah [ DAIICT ].

public class Main {

	public static void main(String[] Args) {
		Scanner in = new Scanner(System.in);
		int mod = 1000000007;
		//HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();
		//ArrayList<Integer> a = new ArrayList<Integer>();
		//Set<Integer> s = new HashSet<Integer>();
		//int[]  a = new int[n];

		int[][]  a = new int[5][5];
		int[][]  c = new int[5][5];

		c[0][0]=3;
		c[0][1]=2;
		c[0][2]=1;

		c[1][0]=0;
		c[1][1]=3;
		c[1][2]=2;

		c[2][0]=1;
		c[2][1]=0;
		c[2][2]=3;

		c[3][0]=2;
		c[3][1]=1;
		c[3][2]=0;

		for(int i=0;i<4;i++) {
			for(int j=0;j<4;j++) {
				a[i][j]=in.nextInt();
			}
		}

		Set<Integer> s = new HashSet<Integer>();
		for(int i=0;i<4;i++) {
			if(a[i][3]==1) {
				s.add(i);
			}
		}

		int f=0;
		for(int i=0;i<4;i++) {
			for(int j=0;j<3;j++) {
				if(a[i][j]==1) {
					if(s.contains(c[i][j])){
						f=1;
					}
				}
			}
		}

		if(f==1) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

		in.close();
	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String result = "NO";
        Scanner sc = new Scanner(System.in);
        boolean [][] arr= new boolean[4][4];
        for(int i = 0; i < 4; i++) {
            String [] s = sc.nextLine().split(" ");

            System.out.println(s.length);
            for(int j = 0;j < s.length; j++) {
                if(s[j] == "0") {
                    arr[i][j] = false;
                } else {
                    arr[i][j] = true;
                }
            }

        }
        for(int i = 0; i < 4; i++) {
            if(arr[i][3] == true) {
                if(arr[i][0] == true && arr[i][1] == true && arr[i][2] == true) {

                    result = "YES";
                    break;
                }
                int tmp;
                if(i == 3) tmp = 0; else tmp = i +2;
                if(arr[i][1] == true && arr[tmp][3] == true) {
                    result = "YES";
                    break;
                }

                if(i == 0) tmp = 3 ; else tmp = i -1;
                if(arr[i][0] == true && arr[tmp][3] == true) {
                    result = "YES";
                    break;
                }
            }

        }

        System.out.println(result);

    }
        }

import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[][] a = new int[4][4];
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                a[i][j] = in.nextInt();
            }
        }
        boolean check = true;
        for (int i = 0; i < 4 && check; i++) {
            for (int j = 0; j < 3 && check; j++) {
                if ((a[i][j] > 0 || a[i][(i + 1) % 4] > 0) && (a[i][3] > 0)) {
                    System.out.println("Yes");
                    check = false;
                }
            }
        }
        if (check) {
            System.out.println("No");
        }

        in.close();
    }
}

import java.io.*;
import java.util.*;

public class SagheerAndCrossroads {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean[] car = new boolean[4];
		for(int i = 0; i<4; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int l = Integer.parseInt(st.nextToken());
			int s = Integer.parseInt(st.nextToken());
			int r = Integer.parseInt(st.nextToken());
			int p = Integer.parseInt(st.nextToken());
			boolean f = (l+s+r)>0;
			if(p==1 && f) {
				System.out.println("YES");
				return;
			}

			if(l==1) {
				if(i==0) {
					if(car[3]) {
						System.out.println("YES");
						return;
					}
					car[3] = true;
				}else {
					if(car[i-1]) {
						System.out.println("YES");
						return;
					}
					car[i-1] = true;
				}
			}else if(s==1) {
				if(car[(i+2)%4]) {
					System.out.println("YES");
					return;
				}
				car[(i+2)%4] = true;
			}else if(r==1) {
				if(i==3) {
					if(car[0]) {
						System.out.println("YES");
						return;
					}
					car[0] = true;
				}else {
					if(car[i+1]) {
						System.out.println("YES");
						return;
					}
					car[i+1] = true;
				}
			}

			if(p==1) {
				if(car[i]) {
					System.out.println("YES");
					return;
				}else {
					car[i] = true;
				}
			}
		}
		System.out.println("NO");
	}
}

import java.util.Scanner;

public class A812 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		boolean[] lanes = new boolean[16];
		boolean[] pedestrian = new boolean[16];
		for(int i = 0; i < 16; i++) {
			if(i % 4 != 3)
				if(scanner.nextInt() == 1)
					lanes[i] = true;
				else
					lanes[i] = false;
			else
				if(scanner.nextInt() == 1)
					pedestrian[i] = true;
				else
					pedestrian[i] = false;
		}

		String result = meetsRequirements(lanes, pedestrian) ? "NO" : "YES";
		System.out.print(result);
	}

	private static boolean meetsRequirements(boolean[] lanes, boolean[] pedestrian) {
		for(int i = 0; i < 16; i++) {
			int row = i / 4;
			int column = i % 4;
			int position = 0;
			if(lanes[i]) {
				if(pedestrian[row])
					return false;
				switch(column) {
					case 0:
						position = (row + 3) % 4;
						if(pedestrian[position])
							return false;
						break;
					case 1:
						position = (row + 2) % 4;
						if(pedestrian[position])
							return false;
						break;
					case 2:
						position = (row + 1) % 4;
						if(pedestrian[position])
							return false;
						break;
				}

			}
		}
		return true;
	}
}

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

public class CF812A {
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int l = 0;
		int r = 1;
		int s = 2;
		int[][] ar = {
				{3,2,1},
				{0,3,2},
				{1,0,3},
				{2,1,0}
		};
		int[][] in = new int[4][4];
		for(int i = 0;i<4;i++)
			for(int j=0;j<4;j++)
				in[i][j] = fr.nextInt();
		//sovle
		boolean ans = true;
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(in[i][j]==1&&in[i][3]==1)
				{
					System.out.println("YES");
					return;
				}
			}
		}
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(in[i][j]==1&&in[ar[i][j]][3]==1)
				{
					System.out.println("YES");
					return;
				}
			}
		}
		System.out.println("NO");
	}

	//Better IO Class
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		public Float nextFloat() {
			return Float.parseFloat(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Solution implements Runnable
{
    private void solve() throws IOException
    {
        //int n = nextInt();

        int[][] array = new int[4][4];

        for (int i = 0; i < 4; i++) {
            boolean hasOne = false;
            for (int j = 0; j < 4; j++) {
                int x = nextInt();
                if (x == 1 && hasOne) {
                    writer.print("YES");
                    return;
                }
                array[i][j] = x;
            }
        }

        int p1 = array[0][3], p2 = array[1][3], p3 = array[2][3], p4 = array[3][3];

        if (p1 == 1 && (array[1][0] == 1 || array[2][1] == 1 || array[3][2] == 1)) {
            writer.print("YES");
            return;
        }
        if (p2 == 1 && (array[0][2] == 1 || array[2][0] == 1 || array[3][1] == 1)) {
            writer.print("YES");
            return;
        }
        if (p3 == 1 && (array[0][1] == 1 || array[1][2] == 1 || array[3][0] == 1)) {
            writer.print("YES");
            return;
        }
        if (p4 == 1 && (array[0][0] == 1 || array[1][1] == 1 || array[2][2] == 1)) {
            writer.print("YES");
            return;
        }

        writer.print("NO");

    }

    private Long sumDiagLR (Long[][] array) {
        long sum = 0;
        int i = 0, j = 0;

        while (i < array.length && j < array.length) {
            sum += array[i][j];
            i++;
            j++;
        }

        return sum;
    }

    private Long sumDiagRL (Long[][] array) {
       long sum = 0;
       int i = array.length-1, j = 0;

       while (i >=0 && j < array.length) {
           sum += array[i][j];
           i--;
           j++;
       }

       return sum;
   }

    private BigInteger factorial( String n )
    {
        BigInteger k = new BigInteger( n );
        BigInteger ans = BigInteger.ONE;

        while ( k.compareTo( BigInteger.ONE ) > 0 )
        {
            ans = ans.multiply( k );
            k = k.subtract( BigInteger.ONE );
        }

        return ans;
    }

    private long combinations( int n, int r )
    {
        return ( factorial( String.valueOf( n ) ).divide( ( new BigInteger( String.valueOf( r ) ).multiply( factorial( String.valueOf( n - r ) ) ) ) ) ).longValue();
    }

    private String binaryXOR( String s1, String s2 )
    {
        BigInteger a = new BigInteger( s1, 2 );
        BigInteger b = new BigInteger( s2, 2 );

        return a.xor( b ).toString( 2 );

    }

    private static void findDP( Node node )
    {
        for ( Node child : node.children )
        {
            if ( child.value > node.value )
            {
                child.dp = Math.max( child.dp, node.dp + 1 );
                //findDP( child );
            }
        }
    }

    private static class Obj implements Comparable<Obj>
    {
        String name;
        int value;

        public Obj( int value )
        {
            this.value = value;
        }

        public Obj( String name, int value )
        {
            this.name = name;
            this.value = value;
        }

        @Override
        public int compareTo( Obj o )
        {
            return o.value - this.value;
        }
    }

    private static class Edge
    {
        PNode src;
        PNode des;
        long cost;

        public Edge (PNode src, PNode des, long cost) {
            this.src = src;
            this.des = des;
            this.cost = cost;
        }
    }

    private static class PNode
    {
        List<Edge> edges;
        long value;
        boolean isTrue;

        public PNode() {
            this.edges = new ArrayList<>(  );
            this.isTrue = false;
        }

        public PNode(long value ) {
           this.edges = new ArrayList<>(  );
           this.isTrue = false;
            this.value = value;
       }
    }

    private static class Node
    {
        long value;
        long dp;
        List<Node> children;
        Node parent;

        public  Node(){};

        public Node( int value )
        {
            this.value = value;
            dp = 1;
            children = new ArrayList<Node>();
        }
    }

    private static boolean isInt( String s )
    {
        if ( s.length() < 1 )
            return false;
        else
        {
            for ( char c : s.toCharArray() )
            {
                if ( c < '0' || c > '9' )
                {
                    return false;
                }
            }
        }

        return true;
    }

    private static Map<String, Integer> findSubString( String s, int k )
    {
        Map<String, Integer> map = new HashMap<>();
        for ( int i = 0; i < s.length() - ( k - 1 ); i++ )
        {
            String str = new String( s.substring( i, i + k ) );
            if ( map.containsKey( str ) )
            {
                map.put( str, map.get( str ) + 1 );
            }
            else
            {
                map.put( str, 1 );

            }
        }

        return map;
    }

    //mergesort

    public static Comparable[] mergeSort( Comparable[] list )
    {
        if ( list.length <= 1 )
        {
            return list;
        }

        Comparable[] left = new Comparable[ list.length / 2 ];
        Comparable[] right = new Comparable[ list.length - left.length ];
        System.arraycopy( list, 0, left, 0, left.length );
        System.arraycopy( list, left.length, right, 0, right.length );

        mergeSort( left );
        mergeSort( right );

        merge( left, right, list );
        return list;
    }

    private static void merge( Comparable[] left, Comparable[] right, Comparable[] result )
    {
        int leftIdx = 0;
        int rightIdx = 0;
        int index = 0;

        while ( leftIdx < left.length && rightIdx < right.length )
        {
            if ( left[ leftIdx ].compareTo( right[ rightIdx ] ) < 0 )
            {
                result[ index++ ] = left[ leftIdx ];
                leftIdx++;
            }
            else
            {
                result[ index++ ] = right[ rightIdx ];
                rightIdx++;
            }
        }

        System.arraycopy( left, leftIdx, result, index, left.length - leftIdx );
        System.arraycopy( right, rightIdx, result, index, right.length - rightIdx );
    }

    public static List<Obj> mergeSort( List<Obj> list )
    {
        if ( list.size() <= 1 )
        {
            return list;
        }

        List<Obj> left = new ArrayList( list.subList( 0, list.size() / 2 ) );
        List<Obj> right = new ArrayList( list.subList( left.size(), list.size() ) );

        left = mergeSort( left );
        right = mergeSort( right );

        list = merge( left, right );

        return list;
    }

    private static List<Obj> merge( List<Obj> left, List<Obj> right )
    {
        int leftCounter = 0, rightCounter = 0;
        List<Obj> result = new ArrayList<>();

        while ( leftCounter < left.size() && rightCounter < right.size() )
        {
            Obj leftItem = left.get( leftCounter );
            Obj rightItem = right.get( rightCounter );

            if ( leftItem.compareTo( rightItem ) < 0 )
            {
                result.add( leftItem );
                leftCounter++;
            }
            else
            {
                result.add( rightItem );
                rightCounter++;
            }
        }

        if ( leftCounter >= left.size() )
            result.addAll( right.subList( rightCounter, right.size() ) );
        else if ( rightCounter >= right.size() )
            result.addAll( left.subList( leftCounter, left.size() ) );

        return result;
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run()
    {
        try
        {
            reader = new BufferedReader( new InputStreamReader( System.in ) );
            tokenizer = null;
            writer = new PrintWriter( System.out );
            solve();
            reader.close();
            writer.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();
    }

    // Arrays.sort(array, Comparator.comparing((int[] arr) -> arr[1]));
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.StringTokenizer;

public class SagheerAndNubianMarket {
	public static int arr[];
	public static long accSum[];
	public static void main(String args[]) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s = sc.nextInt();
		arr = new int [n];
		accSum = new long[n];
		for(int i=0;i<n;i++)
			arr[i] = sc.nextInt();
		Arrays.sort(arr);
		long sum = 0;
		long factor = 0;
		for (int i=0;i<n;i++)
			accSum[i] = (1L*arr[i]) + ((i==0)?0:accSum[i-1]);
		int i;
		for (i=1;i<=n;i++)
		{
			factor += i;
			long newSum = accSum[i-1] + i * factor;
//			System.out.println(newSum);
			if (newSum>s)
				break;
			sum = newSum;
		}
		if (arr[0]>=s)
		{
			System.out.println("0 0");
			return;
		}
		if (i>=n)
			i--;
		System.out.println(i+" "+sum);
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

	}

}

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

public class R417A {

    public static void main (String[] args) throws java.lang.Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int[][] a = new int[4][4];
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++)
                a[i][j] = in.nextInt();
        boolean possible = false;
        for (int i = 0; i < 4; i++) {
            if (((a[i][0] == 1 || a[i][1] == 1 || a[i][2] == 1) && a[i][3] == 1) || (a[i][1] == 1 && a[(i + 2) % 4][3]==1)) {
                possible = true;
                break;
            }
        }
        if (possible)
            w.println("YES");
        else
            w.println("NO");
        w.close();

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public void skip(int x) {
            while (x-- > 0)
                read();
        }

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

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

        public String nextString() {
            return next();
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.lang.Integer;

public class taska {
	public static void main(String args[]) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int[][] lights = new int[4][4];
		for (int i = 0; i < 4; i++) {
			st = new StringTokenizer(in.readLine());
			for (int j = 0; j < 4; j++) {
				lights[i][j] = Integer.parseInt(st.nextToken());
			}
		}

		boolean accident = false;
		outerloop:
		for (int i = 0; i < 4; i++) {
			if (lights[i][3] == 1) {
				for (int j = 0; j < 3; j++) {
					if (lights[i][j] == 1) {
						accident = true;
						break outerloop;
					}
				}
			}
		}

		if (accident == false) {
			for (int i = 0; i < 4; i++) {
				if ((lights[i][0] == '1') && (lights[(i + 3) % 4][0] == '1')) {
					accident = true;
					break;
				}
			}
		}

		if (accident == false) {
			for (int i = 0; i < 4; i++) {
				if ((lights[i][2] == '1') && (lights[(i + 1) % 4][2] == '1')) {
					accident = true;
					break;
				}
			}
		}

		if (accident == false) {
			for (int i = 0; i < 4; i++) {
				if ((lights[i][1] == '1') && (lights[(i + 2) % 4][1] == '1')) {
					accident = true;
					break;
				}
			}
		}

		if (accident) System.out.println("YES");
		else System.out.println("NO");
	}
}

import java.util.*;
public class SagheerandCrossroads {
public static void main(String[]args) {
	Scanner a=new Scanner(System.in);
	boolean f=false;
	boolean g=false;
	for(int j=0;j<4;j++) {
	for(int i=0;i<4;i++) {
		int k=a.nextInt();
		if(i<3) {
			if(k==1)
				f=true;
		}
		else {
			if(f&&k==1) {
				g=true;
				break;
				}
		}
	}
	if(f&&g)
		break;
	f=false;
	g=false;
	}
if(f)
	System.out.println("YES");
else
	System.out.println("NO");
}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A_ {
	public static void main(String[]args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		int [] l= new int[4];
		int [] s= new int[4];
		int [] r= new int[4];
		int [] p= new int[4];
		boolean flag= false;
		for(int i=0; i< 4; i++){
			l[i]= scanner.nextInt();
			s[i]= scanner.nextInt();
			r[i]= scanner.nextInt();
			p[i]= scanner.nextInt();
		}
		if(p[0]==1){
			if(l[0]==1 || s[0] ==1 || r[0] ==1 || l[1]==1 || s[2]==1 || r[3]==1 ){
				System.out.println("YES");
				flag= true;
			}

		}
		if(p[1]==1){
			if(l[1]==1 || s[1] ==1 || r[1] ==1 || l[2]==1 || s[3]==1 || r[0]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		if(p[2]==1){
			if(l[2]==1 || s[2] ==1 || r[2] ==1 || l[3]==1 || s[0]==1 || r[1]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		if(p[3]==1){
			if(l[3]==1 || s[3] ==1 || r[3] ==1 || l[0]==1 || s[1]==1 || r[2]==1 ){
				System.out.println("YES");
				flag= true;
			}
		}
		if(!flag)
			System.out.println("NO");

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

	}

}

import java.io.*;
import java.util.*;

public class Main {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int[][] arr = new int[4][4];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				arr[i][j] = scn.nextInt();
			}
		}
		if ((arr[0][0] == 1 && arr[3][3] == 1) || (arr[0][1] == 1 && (arr[0][3] == 1 || arr[2][3] == 1))) {
			out.println("YES");
		} else if ((arr[1][0] == 1 && arr[0][3] == 1) || (arr[1][1] == 1 && (arr[1][3] == 1 || arr[3][3] == 1))) {
			out.println("YES");
		} else if ((arr[2][0] == 1 && arr[1][3] == 1) || (arr[2][1] == 1 && (arr[2][3] == 1 || arr[0][3] == 1))) {
			out.println("YES");
		} else if ((arr[3][0] == 1 && arr[2][3] == 1) || (arr[3][1] == 1 && (arr[3][3] == 1 || arr[1][3] == 1))) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	void run() throws Exception {
		boolean onlineJudge = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(onlineJudge);
		long time = System.currentTimeMillis();
		solve();
		out.flush();
		if (!onlineJudge) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

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

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

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

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n, boolean isOneInd) {
			int k = isOneInd ? 1 : 0;
			int[] a = new int[n + k];
			for (int i = k; i < n + k; i++)
				a[i] = nextInt();
			return a;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author niquefa_diego
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            final int n = 4;
            boolean l[] = new boolean[n];
            boolean s[] = new boolean[n];
            boolean r[] = new boolean[n];
            boolean p[] = new boolean[n];
            for (int i = 0; i < n; ++i) {
                l[i] = 1 == in.nextInt();
                s[i] = 1 == in.nextInt();
                r[i] = 1 == in.nextInt();
                p[i] = 1 == in.nextInt();
            }

            boolean ans = false;
            for (int i = 0; i < n; ++i) {
                if (l[i] && p[(i + n - 1) % n]) ans = true;
                if (r[i] && p[(i + 1) % n]) ans = true;
                if (s[i] && p[(i + 2) % n]) ans = true;
            }

            out.println(ans ? "YES" : "NO");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer = null;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

import java.util.Scanner;

public class Solution {

	public int calc() throws Exception
	{
		Scanner sc = new Scanner(System.in);

		int[][] mtx = new int [4][4];

		for (int i = 0; i < 4; i++)
		{
			int l = sc.nextInt();
			int s = sc.nextInt();
			int r = sc.nextInt();
			int p = sc.nextInt();

			mtx[i][0] = l;
			mtx[i][1] = s;
			mtx[i][2] = r;
			mtx[i][3] = p;
		}

		int ans = 0;
		for (int i = 0; i < 4; i++)
		{
			int il = i-1;
			if (il < 0)
				il = 3;

			int ir = i + 1;
			if (ir >= 4)
				ir = 0;

			int iff = i + 2;
			if (iff >= 4)
				iff -= 3;

			if (mtx[i][0] == 1 && (mtx[i][3] == 1 || mtx[il][3] ==1 ))
			{
				ans = 1;
				break;
			}

			if (mtx[i][1] == 1 && (mtx[i][3]==1 || mtx[iff][3] == 1))
			{
				ans = 1;
				break;
			}

			if (mtx[i][2]==1 && (mtx[i][3]==1 || mtx[ir][3] == 1))
			{
				ans = 1;
				break;
			}
		}

		return ans;
	}

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub

		Solution sol = new Solution();

		if (sol.calc() == 1)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.lang.StringBuilder;
import java.lang.StringBuffer;
import java.math.BigInteger;
import java.text.DecimalFormat;
@SuppressWarnings("unused")

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		int[][] road = new int[4][4];

		for (int i = 0 ; i < 4 ; i++){
			StringTokenizer st = new StringTokenizer(bf.readLine());
			for (int j = 0 ; j < 4 ; j++){
				road[i][j] = Integer.parseInt(st.nextToken());
			}
		}

		for (int i = 0 ; i < 4 ; i++){
			for (int j = 0 ; j < 3 ; j++){
				if (road[i][j] == 1){
					if (road[i][3] == 1){
						System.out.println("YES");return;
					}
					if(j == 0){
						if (i == 0 && road[3][3] == 1){
							System.out.println("YES");return;
						}
						else if (i > 0){
							if (road[i-1][3] == 1){
								System.out.println("YES");return;
							}
						}
					}
					if (j == 1){
						if (i == 0 && road[2][3] == 1){
							System.out.println("YES");return;
						}
						else if (i == 1 && road[3][3] == 1){
							System.out.println("YES");return;
						}
						else if (i == ((i+1)/2)-1 && road[((i+1)/2)-1][3] == 1){
							System.out.println("YES");return;
						}
					}
					if (j == 2){
						if (i == 3 && road[0][3] == 1){
							System.out.println("YES");return;
						}
						else if (i < 3){
							if (road[i+1][3] == 1){
								System.out.println("YES");return;
							}
						}
					}
				}
			}
		}
		System.out.println("NO");
	}
}

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

public class Crossroads {
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

	public static void main(String args[]) throws Exception {

		class prob {
			public void solve() {
				MyScanner s = new MyScanner();
				int [][]in = new int[4][4];
				for (int i = 0; i < 4; ++i) {
					for (int j = 0; j < 4; ++j) {
						in[i][j] = s.nextInt();
					}
				}

				for (int i = 0; i < 4; ++i) {
					if ((in[i][0] == 1 || in[i][1] == 1 || in[i][2] == 1) && in[i][3] == 1) {
						System.out.print("YES");
						return;
					}
					int oIndx = (i + 2) % 4;
					if (in[i][1] == 1 && in[oIndx][3] == 1) {
						System.out.print("YES");
						return;
					}
					if (in[i][0] == 1) {

						int idx = (i + 3) % 4;
						if (idx != i) {
							if (in[idx][2] == 1) {
								continue;
							}
							else if (in[idx][3] == 1) {
								System.out.print("YES");
								return;
							}
							else if (in[idx][0] == 1) {
								continue;
							}
						}
					}
					if (in[i][2] == 1) {
						int idx = (i + 1) % 4;
						if (idx != i) {
							if (in[idx][0] == 1) {
								continue;
							}
							else if (in[idx][3] == 1) {
								System.out.print("YES");
								return;
							}
							else if (in[idx][2] == 1) {
								continue;
							}
						}
					}
				}
				System.out.print("NO");
			}

		}
		prob s = new prob();
		s.solve();
	}
}

import java.util.*;
public class light
{
    public static void main(String[]args)throws Exception
    {
        Scanner d=new Scanner(System.in);
        int mat[][]=new int[4][4];
        int c=0;
        for(int i=0;i<4;i++)
        for(int j=0;j<4;j++)
           mat[i][j]=d.nextInt();

        for(int i=0;i<4;i++)
        {
       if( mat[i][3]==1)
        {
         for(int j=0;j<4;j++)
         if(mat[i][j]==1)

         c=1;

        }
    }
    if(c==1)
    System.out.println("YES");
    else
    System.out.println("NO");
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class crossRoads {
	public static void main(String[] args) throws IOException {
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line;
		int counter=0;
		int []r=new int[4];
		int []l=new int[4];
		int []s=new int[4];
		int []p=new int[4];
		for(int j=0;j<4;j++)
		{
			line=bf.readLine();
			String [] split=line.split(" ");
			l[counter]=Integer.parseInt(split[0]);
			s[counter]=Integer.parseInt(split[1]);
			r[counter]=Integer.parseInt(split[2]);
			p[counter++]=Integer.parseInt(split[3]);
		}
			for(int i=0;i<l.length;i++)
			{
				if(l[i]==1)
				{
					int target=i-1;
					if(target<0)
					{
						target+=4;
					}
					if(p[target]==1)
					{
						System.out.println("YES");
						return;
					}
				}
				if(s[i]==1)
				{
					int target=i+2;
					if(target>3)
					{
						target-=4;
					}
					if(p[target]==1)
					{
						System.out.println("YES");
						return;
					}
				}

					if(r[i]==1)
					{
						int target=i+1;
						if(target>3)
						{
							target-=4;
						}
						if(p[target]==1)
						{
							System.out.println("YES");
						}
					}
			}
			System.out.println("NO");

		}
}

import java.util.*;

public class CodeForces {

    public static void main(String[] args) {

      boolean q=false;
      int a []=new int [4];
      int b []=new int [4];
      int c []=new int [4];
      int d []=new int [4];
       int k=0;
       Scanner sc=new Scanner(System.in);
      for (int i=0;i<4;i++){
          a[i]=sc.nextInt();
         if (a[i]==1)k++;
      }
      if(a[3]==1&& k>1)q=true;
      k=0;
      for (int i=0;i<4;i++){
         b[i]=sc.nextInt();
         if (b[i]==1)k++;
      }
      if(b[3]==1&&k>1)q=true;
      k=0;

    for (int i=0;i<4;i++){
         c[i]=sc.nextInt();
         if (c[i]==1)k++;
      }
    if(c[3]==1&&k>1)q=true;
      k=0;

      for (int i=0;i<4 ;i++){
          if (d[i]==1)k++;
         d[i]=sc.nextInt();
      }
      if(k>1)q=true;
      k=0;
      if(q==true)System.out.println("Yes");
      else{
          if(a[3]==1){
              if(b[0]==1||c[1]==1||d[2]==1)q=true;
          }
         else if(b[3]==1){
              if(c[0]==1||d[1]==1||a[2]==1)q=true;
          }
        else if(c[3]==1){
              if(d[0]==1||a[1]==1||b[2]==1)q=true;
          }
         else if(d[3]==1){
              if(a[0]==1||b[1]==1||c[2]==1)q=true;
          }
      }
      if (q==true)System.out.println("Yes");
      else System.out.println("No");

          }
}

import java.util.*;

import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        boolean[][] b = new boolean[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                b[i][j] = in.nextInt() == 1;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (b[i][3] && (b[i][0] || b[i][1] || b[i][2])) {
                System.out.println("YES");
                return;
            }
            if (b[i][0] && b[((i - 1) + 4) % 4][3]) {
                System.out.println("YESs");
                return;
            }
            if (b[i][1] && b[(i + 2) % 4][3]) {
                System.out.println("YES");
                return;
            }
            if (b[i][2] && b[(i + 1) % 4][3]) {

                System.out.println("YESs");
                return;
            }
        }
        System.out.println("NO");
    }
}

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

public class R417A {

    public static void main (String[] args) throws java.lang.Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int[][] a = new int[4][4];
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++)
                a[i][j] = in.nextInt();
        boolean possible = false;
        outer:
        for (int i = 0; i < 4; i++) {
            if (i == 0) {
                if (  (a[0][1] == 1 && a[0][3] == 1) || (a[0][1] == 1 && a[2][3] == 1) ) {
                    possible = true;
                    //System.out.println("i is : " + i);
                    break outer;
                }
            }
            if (i == 1) {
                if (  (a[1][1] == 1 && a[1][3] == 1) || (a[1][1] == 1 && a[3][3] == 1) ) {
                    possible = true;
                    //System.out.println("i is : " + i);
                    break outer;
                }
            }
            if (i == 2) {
                if (  (a[2][1] == 1 && a[2][3] == 1) || (a[2][1] == 1 && a[0][3] == 1) ) {
                    possible = true;
                    //System.out.println("i is : " + i);
                    break outer;
                }
            }
            if (i == 3) {
                if (  (a[3][1] == 1 && a[3][3] == 1) || (a[3][1] == 1 && a[2][3] == 1) ) {
                    possible = true;
                    //System.out.println("i is : " + i);
                    break outer;
                }
            }
        }
        if (possible)
            w.println("YES");
        else
            w.println("NO");
        w.close();

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public void skip(int x) {
            while (x-- > 0)
                read();
        }

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

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

        public String nextString() {
            return next();
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

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

public class Main {

 public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int[][] a=new int[4][4];
     for(int i = 0 ;   i < 4 ; i++ ){
         for(int j = 0 ; j < 4 ; j++){
             a[i][j] = sc.nextInt();
         }
     }
     boolean ok = false;
     loop:
     for(int i = 0 ; i < 4 ; i++){
         if(a[i][3]==1){
             for(int j = 0 ; j < 3 ; j++){
                 if(a[(j+i+1)%4][j]==1){
                     ok = true;
                     break loop;
                 }
             }
         }
     }
     System.out.println(ok ? "YES" : "NO");
   }
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int ar[][] = new int[4][4];
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++)
				ar[i][j] = sc.nextInt();
		boolean ans = false;
		for (int i = 0; i < 4; i++) {
			if (ar[i][3] == 1) {
				if (ar[i][1] == 1) {
					ans = true;
					break;
				}
				if (ar[(i + 1) % 4][0] == 1 || ar[(i + 2) % 4][1] == 1 || ar[(i + 3) % 4][2] == 1) {
					ans = true;
					break;
				}

			}

		}
		if (ans == true) {
			System.out.println("YES");
		} else
			System.out.println("NO");
	}

}

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

public class Promotions {
	public static void main(String[]args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int[][]a = new int[4][4];
		for(int i = 0 ; i < 4 ; i ++){
			StringTokenizer tkn = new StringTokenizer(r.readLine());
			for(int j = 0 ; j < 4 ; j++){
				a[i][j]=Integer.parseInt(tkn.nextToken());
			}
		}

		boolean flag = false;
		if(a[0][3]==1){
			if((a[1][0]|a[2][1]|a[3][2]|a[0][1])>0) flag = true;
		}
		if(a[1][3]==1){
			if((a[0][2]|a[2][0]|a[3][1]|a[1][1])>0) flag = true;
		}
		if(a[2][3]==1){
			if((a[0][1]|a[1][2]|a[3][0]|a[2][1])>0) flag = true;
		}
		if(a[3][3]==1){
			if((a[0][0]|a[1][1]|a[2][2]|a[3][1])>0) flag = true;
		}
		System.out.println(flag?"YES":"NO");

	}
}

		// Code Author: Shrey Shah
		// Institute : DA-IICT
		// Quote : Think twice , Code Once

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

			public class Tester5 {

				static double eps=(double)1e-6;
				static long mod=(int)1e9+7;
				static int height[] = new int[100001];
				static boolean[] visited=new boolean[1000001];
				public static void main(String args[]){
					InputReader sc = new InputReader(System.in);
					OutputStream outputStream = System.out;
					PrintWriter out = new PrintWriter(outputStream);
					//----------My Code----------
					String one = sc.nextLine();
					String two = sc.nextLine();
					String three = sc.nextLine();
					String four = sc.nextLine();
					int flag=0;
					if((one.charAt(0)==1 || one.charAt(2)==1 || one.charAt(4)==1)&&one.charAt(6)=='1')
					{
						flag=1;
						out.println("YES");
					}
					if((two.charAt(0)==1 || two.charAt(2)==1 || two.charAt(4)==1)&&two.charAt(6)=='1')
					{
						flag=1;
						out.println("YES");
					}
					if((three.charAt(0)==1 || three.charAt(2)==1 || three.charAt(4)==1)&&three.charAt(6)=='1')
					{
						flag=1;
						out.println("YES");
					}
					if((four.charAt(0)==1 || four.charAt(2)==1 || four.charAt(4)==1)&&four.charAt(6)=='1')
					{
						flag=1;
						out.println("YES");
					}
					//for one
					if(one.charAt(0)=='1')
						if(four.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(one.charAt(2)=='1')
						if(three.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(one.charAt(4)=='1')
						if(two.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}

						//for two
					if(two.charAt(0)=='1')
						if(one.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(two.charAt(2)=='1')
						if(four.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(two.charAt(4)=='1')
						if(three.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}

					//for three

					if(three.charAt(0)=='1')
						if(two.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(three.charAt(2)=='1')
						if(one.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(three.charAt(4)=='1')
						if(four.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}

					//for four

					if(four.charAt(0)=='1')
						if(three.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(four.charAt(2)=='1')
						if(two.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}
					if(four.charAt(4)=='1')
						if(one.charAt(6)=='1')
							if(flag==0)
							{
								out.println("YES");
								flag=1;
							}

					//no accident
					if(flag==0)
						out.println("NO");
				//----------The End----------
					out.close();
				}

				private static long min(long a, long b) {
					// TODO Auto-generated method stub
					 return (a>b)? b:a;
				}

				private static long max(long a, long b) {
					// TODO Auto-generated method stub

					return (a>b)? a:b;
				}

				static int power(int x,int n)
					{
					    if(n==0)
					        return 1;
					    else if(n%2 == 0)        //n is even
					        return power(x*x,n/2);
					    else                             //n is odd
					        return x*power(x*x,(n-1)/2);
					}

				static long ce(long x)
				{
					if(x%2!=0)
						return x/2+1;
					return x/2;
				}
				static boolean isSubSequence(String str1, String str2, int m, int n)
				{
				   int j = 0;
				   for (int i=0; i<n&&j<m; i++)
				       if (str1.charAt(j) == str2.charAt(i))
				         j++;

				   return (j==m);
				}

				static long fibo(long l) {
			        if (l < 0) {
			            throw new IllegalArgumentException("The fibo value cannot be negative");
			        }

			        if (l <= 1) return l;

			        long[][] result = {{1, 0}, {0, 1}}; // identity matrix.
			        long[][] fiboM = {{1, 1}, {1, 0}};

			        while (l > 0) {
			            if (l%2 == 1) {
			                multMatrix(result, fiboM);
			            }
			            l = l / 2;
			            multMatrix(fiboM, fiboM);
			        }

			        return result[1][0];
			    }

			    private static void multMatrix(long[][] result, long[][] fiboM) {
			        long a = (result[0][0]%mod * fiboM[0][0]%mod)%mod +  (result[0][1]%mod * fiboM[1][0]%mod)%mod;
			        long b = (result[0][0]%mod * fiboM[0][1]%mod)%mod + ( result[0][1]%mod * fiboM[1][1]%mod)%mod;
			        long c = (result[1][0]%mod * fiboM[0][0]%mod)%mod + ( result[1][1]%mod * fiboM[0][1]%mod)%mod;
			        long d = (result[1][0]%mod * fiboM[0][1]%mod)%mod +  (result[1][1]%mod * fiboM[1][1]%mod)%mod;

			        result[0][0] = a;
			        result[0][1] = b;
			        result[1][0] = c;
			        result[1][1] = d;
			    }

				static int[] sieve(int n,int[] arr)
				{
					for(int i=2;i*i<=n;i++)
					{
						if(arr[i]==0)
						{
							for(int j=i*2;j<=n;j+=i)
								arr[j]=1;
						}
					}
					return arr;
				}

				static boolean isPal(String s)
				{
					for(int i=0, j=s.length()-1;i<=j;i++,j--)
					{
						if(s.charAt(i)!=s.charAt(j)) return false;
					}
					return true;
				}
				public static String rev(String s)
				{
					StringBuilder sb=new StringBuilder(s);
					sb.reverse();
					return sb.toString();
				}

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

				static long gcd(long a, long b)
				{
				    while (b > 0)
				    {
				        long temp = b;
				        b = a % b; // % is remainder
				        a = temp;
				    }
				    return a;
				}
				static long modulo(long a,long b,long c) {
					long x=1;
					long y=a;
					while(b > 0){
						if(b%2 == 1){
							x=(x*y)%c;
						}
						y = (y*y)%c; // squaring the base
						b /= 2;
					}
					return  x%c;
				}
				public static void debug(Object... o) {
					System.out.println(Arrays.deepToString(o));
				}
				static class Pair implements Comparable<Pair>{
					int x;
					int y;
					int i;
					Pair(int xx,int yy){
						x=xx;
						y=yy;
					}
					public Pair() {
						// TODO Auto-generated constructor stub
					}
					@Override
					public int compareTo(Pair o) {
						return Integer.compare(this.x, o.x);
					}
				}

				static class InputReader {
					public BufferedReader reader;
					public StringTokenizer tokenizer;

					public InputReader(InputStream inputstream) {
						reader = new BufferedReader(new InputStreamReader(inputstream));
						tokenizer = null;
					}

					public String nextLine(){
						String fullLine=null;
						while (tokenizer == null || !tokenizer.hasMoreTokens()) {
							try {
								fullLine=reader.readLine();
							} catch (IOException e) {
								throw new RuntimeException(e);
							}
							return fullLine;
						}
						return fullLine;
					}
					public String next() {
						while (tokenizer == null || !tokenizer.hasMoreTokens()) {
							try {
								tokenizer = new StringTokenizer(reader.readLine());
							} catch (IOException e) {
								throw new RuntimeException(e);
							}
						}
						return tokenizer.nextToken();
					}
					public long nextLong() {
						return Long.parseLong(next());
					}
					public int nextInt() {
						return Integer.parseInt(next());
					}
				}

		}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[][] a = new int[4][4];
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    a[i][j] = in.nextInt();
                }
            }
            for (int i = 0; i < 4; i++) {
                if (a[i][3] == 1) {
                    if (a[(i + 1) % 4][0] == 1 || a[(i + 2) % 4][1] == 1 || a[(i + 3) % 4][2] == 1 || a[i][1] == 1) {
                        out.println("YES");
                        return;
                    }
                }
            }
            out.println("NO");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

import java.util.*;

public class TaskA {
  public static void main (String[] args) {
    Scanner scan = new Scanner(System.in);
    int l1 = scan.nextInt();
    int s1 = scan.nextInt();
    int r1 = scan.nextInt();
    int p1 = scan.nextInt();

    int l2 = scan.nextInt();
    int s2 = scan.nextInt();
    int r2 = scan.nextInt();
    int p2 = scan.nextInt();

    int l3 = scan.nextInt();
    int s3 = scan.nextInt();
    int r3 = scan.nextInt();
    int p3 = scan.nextInt();

    int l4 = scan.nextInt();
    int s4 = scan.nextInt();
    int r4 = scan.nextInt();
    int p4 = scan.nextInt();

    if((s1==1&&p3==1)||(s2==1&&p4==1)||(s3==1&&p1==1)||(s4==1&&p2==1)) {
      System.out.println("YES");
    }
    else if((r1==1&&p2==1)||(r2==1&&p3==1)||(r3==1&&p4==1)||(r4==1&&p1==1)) {
      System.out.println("YES");
    }
    else if((l1==1&&p4==1)||(l2==1&&p1==1)||(l3==1&&p2==1)||(l4==1&&p3==1)) {
      System.out.println("YES");
    }
    else if((s1==1&&p1==1)||(l1==1&&p1==1)||(r1==1&&p1==1)) {
      System.out.println("YES");
    }
    else if((s2==1&&p2==1)||(l2==1&&p2==1)||(r2==1&&p2==1)) {
      System.out.println("YES");
    }
    else if((s3==1&&p3==1)||(l3==1&&p3==1)||(r3==1&&p3==1)) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }

  }
}

import java.io.*;
import java.util.*;

public class ProblemA {

    public static void main(String[] args) throws IOException {
        init();
        new ProblemA().run();
        out.flush();
        out.close();
    }

    static void init() throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in.ordinaryChars(0, 65535);
        in.wordChars(0, 65535);
        in.whitespaceChars(' ', ' ');
        in.whitespaceChars('\n', '\n');
        in.whitespaceChars('\r', '\r');
    }

    // класс для пар
    class Pair<L, R> {
        private final L X;
        private final R Y;

        public Pair(L X, R Y) {
            this.X = X;
            this.Y = Y;
        }

        public L getX() {
            return X;
        }

        public R getY() {
            return Y;
        }

        @Override
        public int hashCode() {
            return X.hashCode() ^ Y.hashCode();
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Pair)) return false;
            Pair pairo = (Pair) o;
            return X.equals(pairo.getX()) && Y.equals(pairo.getY());
        }
    }

    static final long INFL = 200000000000000000L;
    static final int INF = 2000000000;
    static final boolean DEBUG = true;

    static StreamTokenizer in;
    static PrintWriter out;

    static void print(String s) {
        print(s, 0);
    }

    static void print(String s, int debug) {
        if (debug == 0 || DEBUG) {
            out.print(s);
        }
    }

    static void println(String s) {
        println(s, 0);
    }

    static void println(String s, int debug) {
        if (debug == 0 || DEBUG) {
            out.println(s);
        }
    }

    static void printArray(int[] arr) {
        println(Arrays.toString(arr));
    }

    static void printArray(char[] arr) {
        println(Arrays.toString(arr));
    }

    static void printArray(String[] arr) {
        println(Arrays.toString(arr));
    }

    static void sort(int[] a) {
        Random rnd = new Random();
        for (int i = a.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i);
            a[i] ^= a[index];
            a[index] ^= a[i];
            a[i] ^= a[index];
        }
        Arrays.sort(a);
    }

    static char[] inChars;
    static int inCharsInd;

    static String next() throws IOException {
        in.nextToken();
        return in.sval;
    }

    static char nextChar() throws IOException {
        while (inChars == null || inCharsInd >= inChars.length) {
            inChars = next().toCharArray();
            inCharsInd = 0;
        }
        return inChars[inCharsInd++];
    }

    static int nextInt() throws IOException {
        return Integer.valueOf(next());
    }

    static double nextDouble() throws IOException {
        return Double.valueOf(next());
    }

    static long nextLong() throws IOException {
        return Long.valueOf(next());
    }

    private void run() throws IOException {
        solve();
    }

    int K, L, M, N, P;

    private void solve() throws IOException {
        int[][] road = new int[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                road[i][j] = nextInt();
            }
        }
        boolean can = false;
        for (int i = 0; i < 4; i++) {
            if (road[i][3] == 1 && (road[i][1] == 1 || road[(i-1+4)%4][2] == 1
                    || road[(i+1)%4][0] == 1 || road[(i+2)%4][1] == 1)){
                can = true;
                break;
            }
        }
        out.println(can?"YES":"NO");

    }

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package learn1;

import java.util.*;

/**
 *
 * @author aakl
 */
public class Learn1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int[][] inputs = new int[4][4];
        Scanner s = new Scanner(System.in);

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                inputs[i][j] = s.nextInt();
            }
        }

        String answer = "NO";

        for (int i = 0; i < 4; i++) {
            if (i == 0) {
                if (inputs[i][3] == 1) {
                    if (inputs[1][0] == 1 || inputs[2][1] == 1 || inputs[3][2] == 1) {
                        answer = "YES";
                        break;
                    }
                }
            } else {
                if (i == 1) {
                    if (inputs[i][3] == 1) {

                        if (inputs[2][0] == 1 || inputs[3][1] == 1 || inputs[0][2] == 1) {
                            answer = "YES";
                            break;
                        }
                    }
                } else {
                    if (i == 2) {
                        if (inputs[i][3] == 1) {
                            if (inputs[3][0] == 1 || inputs[0][1] == 1 || inputs[1][2] == 1) {
                                answer = "YES";
                                break;
                            }
                        }
                    } else {  //i=3
                        if (inputs[i][3] == 1) {
                            if (inputs[0][0] == 1 || inputs[1][1] == 1 || inputs[2][2] == 1) {
                                answer = "YES";
                                break;
                            }
                        }
                    }
                }
            }
        }

        System.out.println(answer);

    }
}

import java.io.*;
import java.util.*;

public class Main {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int[][] arr = new int[4][4];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				arr[i][j] = scn.nextInt();
			}
		}
		if ((arr[0][0] == 1 && arr[3][3] == 1) || (arr[0][1] == 1 && (arr[0][3] == 1 || arr[2][3] == 1))
				|| (arr[0][2] == 1 && arr[1][3] == 1)) {
			out.println("YES");
		} else if ((arr[1][0] == 1 && arr[0][3] == 1) || (arr[1][1] == 1 && (arr[1][3] == 1 || arr[3][3] == 1))
				|| (arr[1][2] == 1 && arr[2][3] == 1)) {
			out.println("YES");
		} else if ((arr[2][0] == 1 && arr[1][3] == 1) || (arr[2][1] == 1 && (arr[2][3] == 1 || arr[0][3] == 1))
				|| (arr[2][2] == 1 && arr[3][3] == 1)) {
			out.println("YES");
		} else if ((arr[3][0] == 1 && arr[2][3] == 1) || (arr[3][1] == 1 && (arr[3][3] == 1 || arr[1][3] == 1))
				|| (arr[3][2] == 1 && arr[0][3] == 1)) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	void run() throws Exception {
		boolean onlineJudge = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(onlineJudge);
		long time = System.currentTimeMillis();
		solve();
		out.flush();
		if (!onlineJudge) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

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

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

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

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n, boolean isOneInd) {
			int k = isOneInd ? 1 : 0;
			int[] a = new int[n + k];
			for (int i = k; i < n + k; i++)
				a[i] = nextInt();
			return a;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}

import java.awt.Point;
import java.awt.Polygon;
import java.io.PrintWriter;
import java.util.Scanner;

public class AnswerChecker {

	public static void main(String[] args) {

		Scanner  in = new Scanner(System.in);

		for(int i=0; i<4; i++) {
			boolean got = false;

			for(int j=0; j<3; j++) {

				got |= (in.nextInt() == 1);

			}

			if(in.nextInt() == 1 && got) {
				System.out.println("YES");
				return;
			}

		}

		System.out.println("NO");

	}
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A
{
	static PrintWriter out = new PrintWriter(
			new BufferedOutputStream(System.out));
	static MyScanner sc = new MyScanner(System.in);
	static StringBuilder output = new StringBuilder();

	public static void main(String... args)
	{
		boolean[][] lights = new boolean[4][4];
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				lights[i][j] = sc.nextInt() == 1;
			}
		}

		for (int s = 0; s < 4; s++)
		{
			if (lights[0][2] && lights[1][3] ||
				lights[0][1] && lights[2][3] ||
				lights[0][0] && lights[3][3] ||
				lights[0][3] && lights[1][0] ||
				lights[0][3] && lights[1][1] ||
				lights[0][3] && lights[1][2])
			{
				output.append("YES\n");

				eOP();
			}

			//swap
			boolean[] temp = lights[0];
			lights[0] = lights[1];
			lights[1] = lights[2];
			lights[2] = lights[3];
			lights[3] = temp;
		}

		output.append("NO\n");

		eOP();
	}

	private static void eOP()
	{
		System.out.println(output);
		System.exit(0);
	}

	/**
	 * Flatfoot's Scanner with slight modifications.
	 *
	 * @author Flatfoot
	 * @see Source
	 */
	private static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;

		MyScanner(InputStream in)
		{
			this.br = new BufferedReader(new InputStreamReader(in));
		}

		String next()
		{
			while (this.st == null || !this.st.hasMoreElements())
			{
				try
				{
					this.st = new StringTokenizer(this.br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return this.st.nextToken();
		}

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

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

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

		/**
		 * This method has been modified to be a bit more similar to Scanner's
		 *
		 * @author Flatfoot,
		 *         JasonBaby
		 */
		String nextLine()
		{
			if (this.st == null || !this.st.hasMoreElements())
			{
				String str = "";
				try
				{
					str = this.br.readLine();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
				return str;
			}
			else
			{
				StringBuilder str = new StringBuilder();
				while (this.st.hasMoreElements())
				{
					str.append(this.st.nextToken());
					str.append(" ");
				}
				str.deleteCharAt(str.length() - 1);
				return str.toString();
			}
		}

	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String result = "NO";
        Scanner sc = new Scanner(System.in);
        boolean [][] arr= new boolean[4][4];
        for(int i = 0; i < 4; i++) {
            String [] s = sc.nextLine().split(" ");

            for(int j = 0;j < s.length; j++) {
                if(s[j].equals("0")) {
                    arr[i][j] = false;
                } else {

                    arr[i][j] = true;
                }
            }

        }

        for(int i = 0; i < 4; i++) {
            if(arr[i][3] == true) {
                if(arr[i][0] == true || arr[i][1] == true ||  arr[i][2] == true) {
                    result = "YES";
                    break;
                }
                int tmp;
                if(i > 1) tmp = 3 -i; else tmp = i +2;
                if(arr[i][1] == true && arr[tmp][3] == true) {
                    result = "YES";
                    break;
                }

                if(i == 0) tmp = 3 ; else tmp = i -1;
                if(arr[i][0] == true && arr[tmp][3] == true) {
                    result = "YES";
                    break;
                }
            }

        }

        System.out.println(result);

    }
        }

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int[] green = new int[16];
		for(int i = 0 ; i < 16 ; i++) {
			green[i] = sc.nextInt();
			}
		if((green[0]== 1 || green[1]== 1 || green[2] == 1) && green[3] == 1) {
			System.out.println("YES");
			return;
		}
		if((green[4]== 1 || green[5]== 1 || green[6] == 1) && green[7] == 1) {
			System.out.println("YES");
			return;
		}
		if((green[8]== 1 || green[9]== 1 || green[10] == 1) && green[11] == 1) {
			System.out.println("YES");
			return;
		}
		if((green[12]== 1 || green[13]== 1 || green[14] == 1) && green[15] == 1) {
			System.out.println("YES");
			return;
		}
		if(green[3]==1 && green[4] == 1 || green[7]==1 && green[8] == 1 || green[11]==1 && green[12] == 1) {
			System.out.println("YES");return;
		}
		System.out.println("NO");
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class crossRoads {
	public static void main(String[] args) throws IOException {
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line;
		int counter=0;
		int []r=new int[4];
		int []l=new int[4];
		int []s=new int[4];
		int []p=new int[4];
		for(int j=0;j<4;j++)
		{
			line=bf.readLine();
			String [] split=line.split(" ");
			l[counter]=Integer.parseInt(split[0]);
			s[counter]=Integer.parseInt(split[1]);
			r[counter]=Integer.parseInt(split[2]);
			p[counter++]=Integer.parseInt(split[3]);
		}
			for(int i=0;i<l.length;i++)
			{
				if(l[i]==1)
				{
					int target=i-1;
					if(target<0)
					{
						target+=4;
					}
					if(p[target]==1)
					{
						System.out.println("YES");
						return;
					}
				}
				if(s[i]==1)
				{
					int target=i+2;
					if(target>3)
					{
						target-=4;
					}
					if(p[target]==1)
					{
						System.out.println("YES");
						return;
					}
				}

					if(r[i]==1)
					{
						int target=i+1;
						if(target>3)
						{
							target-=4;
						}
						if(p[target]==1)
						{
							System.out.println("YES");
							return;
						}
					}
			}
			System.out.println("NO");

		}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class SagheerandCrossroads
{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int arr_dng []= new int [4];
		int arr_move [] = new int [4];
		for(int i=0;i<4;i++)
		{
			String line []= br.readLine().split(" ");
			if(line[0].charAt(0)=='1')
			{
				arr_dng[(i+3)%4]=1;
				arr_dng[i]=1;
			}
			if(line[1].charAt(0)=='1')
			{
				arr_dng[(i+2)%4]=1;
				arr_dng[i]=1;
			}
			if(line[2].charAt(0)=='1')
			{
				arr_dng[(i+1)%4]=1;
				arr_dng[i]=1;
			}
			if(line[3].charAt(0)=='1')
			{
				arr_move[i]=1;

			}

		}
		boolean dng = false;
		for(int i=0;i<4;i++)
		{
			if(arr_dng[i]==arr_move[i])
			{
				dng = true ;
			}
		}
		if(dng )
			System.out.println("YES");
		else
			System.out.println("NO");

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MASKFOUR {

	public static void main(String[] args) throws IOException {
		BufferedReader axa = new BufferedReader(new InputStreamReader(System.in));
		String [][] x = new String[4][4];
		for(int i =0 ;i<4 ;i++){
			String[] c = axa.readLine().split(" ");
			for(int j =0 ; j<4 ; j++){
				x[i][j] = c[j];}}
		boolean flag = true;
		for(int i = 0 ; i<4 ;i++){
			if(x[i][3].equals("1")){
				for(int j =0 ; j<3 ; j++){
					if(x[i][j].equals("1")){flag=false;break;}
					if(i==0){if(x[3][2].equals("1")){flag=false;break;}
							 if(x[2][1].equals("1")){flag=false;break;}}
					if(i==1){if(x[0][2].equals("1")){flag=false;break;}
							 if(x[3][1].equals("1")){flag=false;break;}}
					if(i==2){if(x[1][2].equals("1")){flag=false;break;}
							 if(x[0][1].equals("1")){flag=false;break;}}
					if(i==3){if(x[2][2].equals("1")){flag=false;break;}
							 if(x[1][1].equals("1")){flag=false;break;}}
					}}
			if(flag==false){break;}
		}
		for(int i = 0 ; i<4 ; i++){
			if(x[i][3].equals("1")){
				for(int j = 0 ; j<3 ; j++){

				}
			}
		}

		if(flag){System.out.println("NO");}
		else{System.out.println("YES");}
		}

}

import java.util.Scanner;
public class TrafficLight {
    public static void main(String[] args) {
        int[][] intersection  = new int[4][4];
        Scanner kb = new Scanner(System.in);
        StringBuilder input = new StringBuilder();
        for(int i = 0; i < 4; i++){
            input.append(kb.nextLine());
            input.append(" ");
        }
        String[] inputs = input.toString().split(" ");
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 4; j++){
                intersection[i][j] = Integer.parseInt(inputs[(i*4) + j]);
            }
        }

        boolean nocrash =  true;

        for(int i = 0; i < 4; i++){
            if(intersection[i][3] == 1){
                if(intersection[i][1] == 1 || intersection[(i + 1) % 4][0] == 1 || intersection[(i+2) % 4][1] == 1 || intersection[(i+3) % 4][2] == 1){
                    nocrash = false;
                }
            }
        }
        if(nocrash){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Solution implements Runnable
{
    private void solve() throws IOException
    {
        //int n = nextInt();

        int[][] array = new int[4][4];

        for (int i = 0; i < 4; i++) {
            boolean hasOne = false;
            for (int j = 0; j < 4; j++) {
                int x = nextInt();
                if (x == 1 && hasOne) {
                    writer.print("YES");
                    return;
                }
                array[i][j] = x;
            }
        }

        final int row0 = 0, row1 = 1, row2 = 2, row3 = 3;
        final int l = 0, s = 1, r = 2, p = 3;

        int p1 = array[row0][p], p2 = array[row1][p], p3 = array[row2][p], p4 = array[row3][p];

        if (p1 == 1 && (array[row1][l] == 1 || array[row2][s] == 1 || array[row3][r] == 1)) {
            writer.print("YES");
            return;
        }
        if (p2 == 1 && (array[row0][r] == 1 || array[row2][l] == 1 || array[row3][s] == 1)) {
            writer.print("YES");
            return;
        }
        if (p3 == 1 && (array[row0][s] == 1 || array[row1][r] == 1 || array[row3][l] == 1)) {
            writer.print("YES");
            return;
        }
        if (p4 == 1 && (array[row0][l] == 1 || array[row1][s] == 1 || array[row2][r] == 1)) {
            writer.print("YES");
            return;
        }

        writer.print("NO");

    }

    private Long sumDiagLR (Long[][] array) {
        long sum = 0;
        int i = 0, j = 0;

        while (i < array.length && j < array.length) {
            sum += array[i][j];
            i++;
            j++;
        }

        return sum;
    }

    private Long sumDiagRL (Long[][] array) {
       long sum = 0;
       int i = array.length-1, j = 0;

       while (i >=0 && j < array.length) {
           sum += array[i][j];
           i--;
           j++;
       }

       return sum;
   }

    private BigInteger factorial( String n )
    {
        BigInteger k = new BigInteger( n );
        BigInteger ans = BigInteger.ONE;

        while ( k.compareTo( BigInteger.ONE ) > 0 )
        {
            ans = ans.multiply( k );
            k = k.subtract( BigInteger.ONE );
        }

        return ans;
    }

    private long combinations( int n, int r )
    {
        return ( factorial( String.valueOf( n ) ).divide( ( new BigInteger( String.valueOf( r ) ).multiply( factorial( String.valueOf( n - r ) ) ) ) ) ).longValue();
    }

    private String binaryXOR( String s1, String s2 )
    {
        BigInteger a = new BigInteger( s1, 2 );
        BigInteger b = new BigInteger( s2, 2 );

        return a.xor( b ).toString( 2 );

    }

    private static void findDP( Node node )
    {
        for ( Node child : node.children )
        {
            if ( child.value > node.value )
            {
                child.dp = Math.max( child.dp, node.dp + 1 );
                //findDP( child );
            }
        }
    }

    private static class Obj implements Comparable<Obj>
    {
        String name;
        int value;

        public Obj( int value )
        {
            this.value = value;
        }

        public Obj( String name, int value )
        {
            this.name = name;
            this.value = value;
        }

        @Override
        public int compareTo( Obj o )
        {
            return o.value - this.value;
        }
    }

    private static class Edge
    {
        PNode src;
        PNode des;
        long cost;

        public Edge (PNode src, PNode des, long cost) {
            this.src = src;
            this.des = des;
            this.cost = cost;
        }
    }

    private static class PNode
    {
        List<Edge> edges;
        long value;
        boolean isTrue;

        public PNode() {
            this.edges = new ArrayList<>(  );
            this.isTrue = false;
        }

        public PNode(long value ) {
           this.edges = new ArrayList<>(  );
           this.isTrue = false;
            this.value = value;
       }
    }

    private static class Node
    {
        long value;
        long dp;
        List<Node> children;
        Node parent;

        public  Node(){};

        public Node( int value )
        {
            this.value = value;
            dp = 1;
            children = new ArrayList<Node>();
        }
    }

    private static boolean isInt( String s )
    {
        if ( s.length() < 1 )
            return false;
        else
        {
            for ( char c : s.toCharArray() )
            {
                if ( c < '0' || c > '9' )
                {
                    return false;
                }
            }
        }

        return true;
    }

    private static Map<String, Integer> findSubString( String s, int k )
    {
        Map<String, Integer> map = new HashMap<>();
        for ( int i = 0; i < s.length() - ( k - 1 ); i++ )
        {
            String str = new String( s.substring( i, i + k ) );
            if ( map.containsKey( str ) )
            {
                map.put( str, map.get( str ) + 1 );
            }
            else
            {
                map.put( str, 1 );

            }
        }

        return map;
    }

    //mergesort

    public static Comparable[] mergeSort( Comparable[] list )
    {
        if ( list.length <= 1 )
        {
            return list;
        }

        Comparable[] left = new Comparable[ list.length / 2 ];
        Comparable[] right = new Comparable[ list.length - left.length ];
        System.arraycopy( list, 0, left, 0, left.length );
        System.arraycopy( list, left.length, right, 0, right.length );

        mergeSort( left );
        mergeSort( right );

        merge( left, right, list );
        return list;
    }

    private static void merge( Comparable[] left, Comparable[] right, Comparable[] result )
    {
        int leftIdx = 0;
        int rightIdx = 0;
        int index = 0;

        while ( leftIdx < left.length && rightIdx < right.length )
        {
            if ( left[ leftIdx ].compareTo( right[ rightIdx ] ) < 0 )
            {
                result[ index++ ] = left[ leftIdx ];
                leftIdx++;
            }
            else
            {
                result[ index++ ] = right[ rightIdx ];
                rightIdx++;
            }
        }

        System.arraycopy( left, leftIdx, result, index, left.length - leftIdx );
        System.arraycopy( right, rightIdx, result, index, right.length - rightIdx );
    }

    public static List<Obj> mergeSort( List<Obj> list )
    {
        if ( list.size() <= 1 )
        {
            return list;
        }

        List<Obj> left = new ArrayList( list.subList( 0, list.size() / 2 ) );
        List<Obj> right = new ArrayList( list.subList( left.size(), list.size() ) );

        left = mergeSort( left );
        right = mergeSort( right );

        list = merge( left, right );

        return list;
    }

    private static List<Obj> merge( List<Obj> left, List<Obj> right )
    {
        int leftCounter = 0, rightCounter = 0;
        List<Obj> result = new ArrayList<>();

        while ( leftCounter < left.size() && rightCounter < right.size() )
        {
            Obj leftItem = left.get( leftCounter );
            Obj rightItem = right.get( rightCounter );

            if ( leftItem.compareTo( rightItem ) < 0 )
            {
                result.add( leftItem );
                leftCounter++;
            }
            else
            {
                result.add( rightItem );
                rightCounter++;
            }
        }

        if ( leftCounter >= left.size() )
            result.addAll( right.subList( rightCounter, right.size() ) );
        else if ( rightCounter >= right.size() )
            result.addAll( left.subList( leftCounter, left.size() ) );

        return result;
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run()
    {
        try
        {
            reader = new BufferedReader( new InputStreamReader( System.in ) );
            tokenizer = null;
            writer = new PrintWriter( System.out );
            solve();
            reader.close();
            writer.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();
    }

    // Arrays.sort(array, Comparator.comparing((int[] arr) -> arr[1]));
}

import java.util.Scanner;
public class Class2 {
    public static void main(String[] args) {
        Scanner s = new Scanner (System.in);

        int [][]ar = new int[4][4];
        String a ;
        for(int i=0; i<4; i++)
        for(int j=0; j<4; j++){
             ar[i][j]= Integer.parseInt(s.next());
        }

        if(ar[0][3]== 1 && (ar[1][0]==1|| ar[2][1]==1|| ar[3][3]==1))
        System.out.println("YES");
        else
        if(ar[1][3]==1&&(ar[0][3]==1|| ar[2][0]==1|| ar[3][1]==1))
        System.out.println("YES");
        else
        if(ar[2][3]==1&&(ar[0][1]==1|| ar[1][2]==1|| ar[2][0]==1))
        System.out.println("YES");
        else
        if(ar[3][3]==1&&(ar[0][2]==1|| ar[1][1]==1|| ar[2][2]==1))
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MASKFOUR {

	public static void main(String[] args) throws IOException {
		BufferedReader axa = new BufferedReader(new InputStreamReader(System.in));
		String [][] x = new String[4][4];
		for(int i =0 ;i<4 ;i++){
			String[] c = axa.readLine().split(" ");
			for(int j =0 ; j<4 ; j++){
				x[i][j] = c[j];}}
		boolean flag = true;
		for(int i = 0 ; i<4 ;i++){
			if(x[i][3].equals("1")){
				for(int j =0 ; j<3 ; j++){
					int c = i;
					if(x[i][j].equals("1")){flag=false;break;}
					if(i==0){if(x[1][0].equals("1")){flag=false;break;}}
					if(i==1){if(x[2][1].equals("1")){flag=false;break;}}
					if(i==2){if(x[3][2].equals("1")){flag=false;break;}}
				}}
			if(flag==false){break;}
		}

		if(flag){System.out.println("NO");}
		else{System.out.println("YES");}
		}

}

import java.util.Scanner;

public class Main {
	public static void main(String atgs[]) {
		Scanner sc = new Scanner(System.in);
		boolean accident = false;
		String l = " " + sc.nextLine().replace(" ", ""), s = " " + sc.nextLine().replace(" ", ""),
				r = " " + sc.nextLine().replace(" ", ""), p = " " + sc.nextLine().replace(" ", "");
		for (int i = 1; i <= 4; i++) {
			if (i == 1) {
				if (p.charAt( i) == '1' &&(s.charAt(3) == '1' || r.charAt(4) == '1' || l.charAt(2) == '1' || s.charAt(i) == '1'
						|| r.charAt(i) == '1')) {
					accident = true;
				}

			} else if (i == 2) {
				if (p.charAt( i) == '1' && (s.charAt(4) == '1' || r.charAt(1) == '1' || l.charAt(3) == '1' || s.charAt(i) == '1'
						|| r.charAt(i) == '1')) {
					accident = true;
				}
			} else {
				if (p.charAt( i) == '1' && (s.charAt(i - 2) == '1' || r.charAt(i - 1) == '1' || l.charAt(i - 3) == '1' || s.charAt(i) == '1'
						|| r.charAt(i) == '1')) {
					accident = true;
				}
			}
		}
		if (!accident)
			System.out.println("NO");
		else
			System.out.println("YES");

	}
}

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

public class Crossroads {
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

	public static void main(String args[]) throws Exception {

		class prob {
			public void solve() {
				MyScanner s = new MyScanner();
				int [][]in = new int[4][4];
				for (int i = 0; i < 4; ++i) {
					for (int j = 0; j < 4; ++j) {
						in[i][j] = s.nextInt();
					}
				}

				for (int i = 0; i < 4; ++i) {
					if ((in[i][1] == 1 || in[i][2] == 1) && in[i][3] == 1) {
						System.out.print("YES");
						return;
					}
					if (in[i][0] == 1) {

						int idx = (i + 3) % 4;
						if (idx != i) {
							if (in[idx][2] == 1) {
								continue;
							}
							else if (in[idx][3] == 1) {
								System.out.print("YES");
								return;
							}
							else if (in[idx][0] == 1) {
								continue;
							}
						}
					}
					if (in[i][2] == 1) {
						int idx = (i + 1) % 4;
						if (idx != i) {
							if (in[idx][0] == 1) {
								continue;
							}
							else if (in[idx][3] == 1) {
								System.out.print("YES");
								return;
							}
							else if (in[idx][2] == 1) {
								continue;
							}
						}
					}
				}
				System.out.print("NO");
			}

		}
		prob s = new prob();
		s.solve();
	}
}