Problem: Problem

There is a puzzle game where you move curling stones and stack them exactly on the goal square. The detailed rules are as follows.

The field consists of H × W squares, with stones placed in some squares at the beginning. There is only one goal square, and no stone is placed on the goal square from the beginning. In addition, the field is surrounded by an outer wall, so stones will not jump out of the field on the way.

Players can choose one stone for each move and launch it in either the up, down, left, or right direction to slide it. A slipping stone will continue to slide until it hits another stone or the outer wall of the field. If it hits another stone, the stone on the hit side will be recoiled and will slide in a chain in the same direction as the first shot.

For example, when stone A is launched to the right in the state of FIG. 1, the final state is as shown in FIG.

Figure 1


Figure 1





Figure 2


Figure 2





The condition for clearing this puzzle is to place one of the stones on the field exactly on the goal square. It will not be cleared if you pass the goal square.

Your job is to create a program that takes the initial state of the field as input and outputs whether the puzzle is clear or not.

Constraints

* 1 ≤ H ≤ 16
* 1 ≤ W ≤ 16
* 2 ≤ H x W ≤ 256
* Guaranteed to have only one goal square
* Guaranteed to have at least one square with curling stones on it

Input

The input is given in the following format.


H W
F11 F12 ... F1W
F21 F22 ... F2W
...
FH1 FH2 ... FHW


Fij is either'.',' O', or'@', and each has the following meaning. (1 ≤ i ≤ H, 1 ≤ j ≤ W)

*'.': Blank cell
*'o': The square on which the curling stone is placed
*'@': Goal square

Output

Print "yes" or "no" (not including "") on one line to see if the puzzle is clear.

Examples

Input

1 10
o........@


Output

yes


Input

3 6
......
.o..@.
......


Output

no


Input

6 4
....
.oo.
.oo.
....
.@..
....


Output

yes

Solution (in CPP):

Solution:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Point
{
public:
    int y, x;
    Point(){
        y = x = 0;
    }
    Point(int y0, int x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(int a) const{
        return Point(y * a, x * a);
    }
    bool operator==(const Point& p) const{
        return y == p.y && x == p.x;
    }
    bool operator<(const Point& p) const{
        return make_pair(y, x) < make_pair(p.y, p.x);
    }
};

const Point d[] = {Point(0, -1), Point(0, 1), Point(1, 0), Point(-1, 0)};

int main()
{
    int h, w;
    cin >> h >> w;

    vector<Point> init;
    Point goal;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            char c;
            cin >> c;
            if(c == 'o')
                init.push_back(Point(y, x));
            else if(c == '@')
                goal = Point(y, x);
        }
    }
    if(min(h, w) != 1 && init.size() > 2){
        cout << "yes" << endl;
        return 0;
    }

    set<vector<Point> > history;
    queue<vector<Point> > q;
    history.insert(init);
    q.push(init);
    while(!q.empty()){
        vector<Point> v = q.front();
        q.pop();
        for(unsigned i=0; i<v.size(); ++i){
            if(v[i] == goal){
                cout << "yes" << endl;
                return 0;
            }
        }

        for(unsigned i=0; i<v.size(); ++i){
            for(int j=0; j<4; ++j){
                vector<Point> v2 = v;
                for(;;){
                    Point p = v2[i] + d[j];
                    if(!(0 <= p.y && p.y < h && 0 <= p.x && p.x < w))
                        break;

                    for(unsigned k=0; k<v.size(); ++k){
                        if(v2[k] == p)
                            v2[k] = v2[k] - d[j];
                    }
                    v2[i] = p;
                }

                sort(v2.begin(), v2.end());
                if(history.find(v2) == history.end()){
                    history.insert(v2);
                    q.push(v2);
                }
            }
        }
    }

    cout << "no" << endl;
    return 0;
}