Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.

In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins immediately.

Alice wins if some crosses in the field form line of length not smaller than 5. This line can be horizontal, vertical and diagonal.

Input

You are given matrix 10 × 10 (10 lines of 10 characters each) with capital Latin letters 'X' being a cross, letters 'O' being a nought and '.' being an empty cell. The number of 'X' cells is equal to the number of 'O' cells and there is at least one of each type. There is at least one empty cell.

It is guaranteed that in the current arrangement nobody has still won.

Output

Print 'YES' if it's possible for Alice to win in one turn by putting cross in some empty cell. Otherwise print 'NO'.

Examples

Input

XX.XX.....
.....OOOO.
..........
..........
..........
..........
..........
..........
..........
..........


Output

YES


Input

XXOXX.....
OO.O......
..........
..........
..........
..........
..........
..........
..........
..........


Output

NO
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
 

public class Main {
	static class ReaderForJava{
	    
	    final private int BUFFER_SIZE = 1 << 16;
	    private DataInputStream din;
	    private byte[] buffer;
	    private int bufferPointer, bytesRead;
	 
	    public ReaderForJava()
	    {
	        din = new DataInputStream(System.in);
	        buffer = new byte[BUFFER_SIZE];
	        bufferPointer = bytesRead = 0;
	    }
	 
	    public ReaderForJava(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();
	    }
	}
	static class Pair{
		public int first;
		public int second;
		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}
	}
	static boolean foundResult = false;
	static int length = 10;
	static void generatePossibleWin(int [][] matrix, int [][] visited, int currentX, int currentY, int currentMovement, int currentCost, String direction) {
		if (currentCost > 1) {
			return;
		}
		if (foundResult) {
			return;
		}
		if (currentMovement == 5) {
			foundResult = true;
			return;
		}
		
		if (visited[currentX][currentY] != 1) {
			visited[currentX][currentY] = 1;
			if (direction.equals("UP")) {
				if (currentX > 0) {
					if (matrix[currentX - 1][currentY] != -1) {
						if (matrix[currentX -1][currentY] == 1) {
							generatePossibleWin(matrix, visited, currentX - 1, currentY, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX - 1, currentY, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			} else if (direction.equals("DOWN")) {
				if (currentX < length - 1) {
					if (matrix[currentX + 1][currentY] != -1) {
						if (matrix[currentX + 1][currentY] == 1) {
							generatePossibleWin(matrix, visited, currentX + 1, currentY, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX + 1, currentY, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			} else if (direction.equals("LEFT")) {
				if (currentY > 0) {
					if (matrix[currentX][currentY - 1] != -1) {
						if (matrix[currentX][currentY - 1] == 1) {
							generatePossibleWin(matrix, visited, currentX, currentY - 1, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX, currentY - 1, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			} else if (direction.equals("RIGHT")) {
				if (currentY < length - 1) {
					if (matrix[currentX][currentY + 1] != -1) {
						if (matrix[currentX][currentY + 1] == 1) {
							generatePossibleWin(matrix, visited, currentX, currentY + 1, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX, currentY + 1, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			} else if (direction.equals("DIAGONAL_LEFT_UP")) {
				if (currentX > 0 && currentY > 0) {
					if (matrix[currentX - 1][currentY - 1] != -1) {
						if (matrix[currentX - 1][currentY - 1] == 1) {
							generatePossibleWin(matrix, visited, currentX - 1, currentY - 1, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX - 1, currentY - 1, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			} else if (direction.equals("DIAGONAL_LEFT_DOWN")) {
				if (currentX < length - 1 && currentY > 0) {
					if (matrix[currentX + 1][currentY - 1] != -1) {
						if (matrix[currentX + 1][currentY - 1] == 1) {
							generatePossibleWin(matrix, visited, currentX + 1, currentY - 1, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX + 1, currentY - 1, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			} else if (direction.equals("DIAGONAL_RIGHT_UP")) {
				if (currentX > 0 && currentY < length - 1) {
					if (matrix[currentX - 1][currentY + 1] != -1) {
						if (matrix[currentX - 1][currentY + 1] == 1) {
							generatePossibleWin(matrix, visited, currentX - 1, currentY + 1, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX - 1, currentY + 1, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			} else if (direction.equals("DIAGONAL_RIGHT_DOWN")) {
				if (currentX < length - 1 && currentY < length - 1) {
					if (matrix[currentX + 1][currentY + 1] != -1) {
						if (matrix[currentX + 1][currentY + 1] == 1) {
							generatePossibleWin(matrix, visited, currentX + 1, currentY + 1, currentMovement + 1, currentCost, direction);
						} else {
							generatePossibleWin(matrix, visited, currentX + 1, currentY + 1, currentMovement + 1, currentCost + 1, direction);
						}
					}
				}
			}
		}
	}


	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int matrix[][] = new int [length][length];
		ReaderForJava reader = new ReaderForJava();
		int XCounter = 0;
		int startingX = -1;
		int startingY = -1;
		List <Pair> XPositions = new LinkedList<>();
		for (int i = 0; i < length; i++) {
			String line = reader.readLine().replace("\r", "");
			char[] lineAsChar = line.toCharArray();
			for (int j = 0; j < length; j++) {
				char currentChar= lineAsChar[j];
				if (currentChar == 'X') {
					if (startingX == -1) {
						startingX = i;
						startingY = j;
					}
					Pair currentPair = new Pair(i,j);
					XPositions.add(currentPair);
					matrix[i][j] = 1;
					XCounter++;
				} else if (currentChar == 'O') {
					matrix[i][j] = -1;
				}
			}
		}
		if (XCounter < 4) {
			System.out.println("NO");
			return;
		}
		
		
		int currentX = XPositions.size();
		for (int i = 0; i < currentX; i++) {
			Pair currentPair = XPositions.get(i);
			int [][]visited = new int[length][length];
			if (!foundResult) {
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"LEFT");
			}
			if (!foundResult) {
				visited = new int[length][length];
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"RIGHT");
			}
			if (!foundResult) {
				visited = new int[length][length];
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"UP");
			}
			if (!foundResult) {
				visited = new int[length][length];
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"DOWN");
			}	
			if (!foundResult) {	
				visited = new int[length][length];
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"DIAGONAL_LEFT_UP");
			}
			if (!foundResult) {
				visited = new int[length][length];
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"DIAGONAL_LEFT_DOWN");
			}
			if (!foundResult) {
				visited = new int[length][length];
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"DIAGONAL_RIGHT_UP");
			}
			if (!foundResult) {
				visited = new int[length][length];
				generatePossibleWin(matrix, visited, currentPair.first, currentPair.second, 1, 0,"DIAGONAL_RIGHT_DOWN");
			} 
			if (foundResult){
				break;
			}
		}
		if (!foundResult) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
			
	}
}

// 1511790129440
