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.File;
import java.io.FileReader;
import java.io.IOException;
import static java.lang.System.out;
import java.util.Arrays;
import java.util.Scanner;

/*
 * place X on 10x10 grid, check if going to win in next move
 */

public class FiveInRow {
    String []board=new String[10];
    
    static boolean checkOne(char[] seq, int s)
    {
        int x=1;
        int dot=0;
        int end=s+1;
        //out.println(Arrays.toString(seq)+" "+s);
        for (; end<seq.length; end++) {
            if (seq[end]=='X') {
                x++;
            } else if (seq[end]=='.') {
                if (dot>0)
                    return false;
                dot++;            
            }
            else
                break;
            if (dot+x==5)
                break;            
        }
        if (x<4)
            return false;
        if (dot==1)
            return true;
        if ( s>0 && seq[s-1]=='.')
            return true;
        if (end==seq.length)
            return false;
        return seq[end]=='.';
    }
    // find any 5 in a row in a sequence
    static boolean scanSequence(char[] seq)
    {
        //out.println(Arrays.toString(seq)+" scan");
        if (seq.length<5)
            return false;
        boolean skip=false;
        for (int i=0; i<seq.length; i++) {
            if (seq.length-i<4)
                return false;
            if (seq[i]=='X') {
                if (skip)
                    continue;
                if (checkOne(seq, i))
                    return true;
                skip=true;  // skip next X
            } else
                skip=false;
        }
        return false;
    }
    boolean horizontal(int i, int j)
    {
        int x=1;
        int dot=0;
        if (j>6)
            return false;
        for (int k=j+1; k<10; k++) {
            if (board[i].charAt(k)=='X')
                x++;
            else if (board[i].charAt(k)=='.') {
                if (dot>0)
                    return false;
                dot++;
            }
            else
                break;
            if (dot+x==5)
                break;
        }
        if (x<4)
            return false;
        if (dot==1)
            return true;
        if ( j>0 && board[i].charAt(j-1)=='.')
            return true;
        if ( j<6 && board[i].charAt(j+4)=='.')
            return true;
        return false;
    }
    
    boolean vertical(int i, int j)
    {
        int x=1;
        int dot=0;
        if (i>6)
            return false;
        for (int k=i+1; k<10; k++) {
            if (board[k].charAt(j)=='X')
                x++;
            else if (board[k].charAt(j)=='.') {
                if (dot>0)
                    return false;
                dot++;
            }
            else
                break;
            if (dot+x==5)
                break;
        }
        if (x<4)
            return false;
        if (dot==1)
            return true;
        if ( i>0 && board[i-1].charAt(j)=='.')
            return true;
        if ( i<6 && board[i+4].charAt(j)=='.')
            return true;
        return false;
    }
    
    boolean backward(int i, int j)
    {
        int x=1;
        int dot=0;
        int ij=i>j?i-j:j-i;
        if (ij>5 || j<3 || i>6)
            return false;
        for (int k=i+1, m=j-1; k<10 && m>=0; k++, m--) {
            if (board[k].charAt(m)=='X')
                x++;
            else if (board[k].charAt(m)=='.') {
                if (dot>0)
                    return false;
                dot++;
            }
            else
                break;
            if (dot+x==5)
                break;
        }
        if (x<4)
            return false;
        if (dot==1)
            return true;
        if ( i>0 && j<9 && board[i-1].charAt(j+1)=='.')
            return true;
        if ( i<6 && j>0 && board[i+4].charAt(j-1)=='.')
            return true;
        return false;
    }
      
    
    boolean forward(int i, int j)
    {
        int x=1;
        int dot=0;
        int ij=i+j;
        if (ij<4 || ij>14 || j<3 || i>6)
            return false;
        for (int k=i+1, m=j-1; k<10 && m>=0; k++, m--) {
            if (board[k].charAt(m)=='X')
                x++;
            else if (board[k].charAt(m)=='.') {
                if (dot>0)
                    return false;
                dot++;
            }
            else
                break;
            if (dot+x==5)
                break;
        }
        if (x<4)
            return false;
        if (dot==1)
            return true;
        if ( i>0 && j<9 && board[i-1].charAt(j+1)=='.')
            return true;
        if ( i<6 && j>0 && board[i+4].charAt(j-1)=='.')
            return true;
        return false;
    }
    
    FiveInRow()
    {
        for (int i=0; i<board.length; i++)
            board[i]=sc.next();
    }
    
    boolean solve()
    {
        char seq[]=new char[board.length];
        for (int i=0; i<board.length; i++) {
            for (int j=0; j<board[i].length(); j++) //horizontal
                seq[j]=board[i].charAt(j);
            if ( scanSequence(seq) )
                return true;
            
            for (int j=0; j<board[i].length(); j++) //vertical
                seq[j]=board[j].charAt(i);
            if ( scanSequence(seq) )
                return true;            
        }
        for (int i=4; i<10; i++) { 
            // from (0,0) to (9,9), forward diagonal
            //r+c=i
            seq = new char[i+1];
            for (int j=0; j<=i; j++)
                seq[j]=board[i-j].charAt(j);
            if ( scanSequence(seq) )
                return true;  
            if (i<9) {
                for (int j=0; j<=i; j++)
                    seq[j]=board[9-j].charAt(9-i+j);    // r+c=18-i   
                if ( scanSequence(seq) )
                    return true;  
            }
            // from (9, 0) to (0,9), backward diagonal 
            for (int j=i; j>=0; j--)
                seq[j]=board[j+9-i].charAt(j); // r-c=9-i
            if ( scanSequence(seq) )
                return true;  
            if (i<9) {
                for (int j=9-i; j<10; j++)
                    seq[j+i-9]=board[j+i-9].charAt(j); //c-r=9-i
                if ( scanSequence(seq) )
                    return true;  
            }
        }
        return false;
    }
    
    static void test()
    {
        out.println(scanSequence(new char []{'X', 'X', 'X', 'X', '.'}));
        out.println(scanSequence(new char []{'.', 'X', 'X', 'X', 'X'}));
        out.println(scanSequence(new char []{'X', 'X', '.', 'X', 'X'}));
        out.println(scanSequence(new char []{'X', 'X', 'X', 'X', 'O'}));
        out.println(scanSequence(new char []{'X', 'X', '.', 'X', '.'}));
        out.println(scanSequence(new char []{'X', 'X', '.', 'X', '.','X','X','X'}));
    }
   
    public static Scanner getFileScanner(String file)
    {
        try {
            return new Scanner( new FileReader( new File(file)));
        }
        catch (IOException e)
        {
        }
        return new Scanner(System.in);
    }
    static void test2()
    {
        sc=getFileScanner(".\\test\\FiveInARow-t.txt");
        int T=sc.nextInt();
        while (T-->0) {
            String result=new FiveInRow().solve()?"YES":"NO";
            String expect = sc.next();
            out.println(result.equals(expect)?"Pass":"Fail");
        }
    }

    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args)
    {     
        out.println(new FiveInRow().solve()?"YES":"NO");
    }
}
