#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

typedef struct UnionFindTree{
    vector<int> par;

    UnionFindTree(int n){
        par.resize(n, -1);
    }

    bool is_root(int x){
        return par[x] < 0;
    }

    int find(int x){
        if(is_root(x)) return x;
        return par[x] = find(par[x]);
    }

    int size(int x){
        return -par[find(x)];
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void clear(){
        fill(par.begin(), par.end(), -1);
    }
}UF;

using panel = vector<string>;

int n, m;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void rot(panel &a){
    panel b = a;
    rep(i, n)rep(j, n) b[j][n-1-i] = a[i][j];
    rep(i, n)rep(j, n) a[i][j] = b[i][j];
}

void normalize(vector<int> &state){
    map<int, int> id;
    rep(i, state.size()){
        if(id.find(state[i]) == id.end()){
            id[state[i]] = i;
            state[i] = i;
        }
        else state[i] = id[state[i]];
    }
    return;
}

void solve(){
    vector<panel> ps(m);
    rep(i, m){
        ps[i].resize(n);
        rep(j, n) cin >> ps[i][j];
    }
    set<vector<int>> prev_states, new_states;
    rep(new_panel, m){
        rep(_, 4){
            UF uf(n * n);
            rep(x, n)rep(y, n)if(ps[new_panel][x][y] == '.'){
                rep(i, 4){
                    int nx = x + dx[i], ny = y + dy[i];
                    if(0 <= nx && nx < n && 0 <= ny && ny < n && ps[new_panel][nx][ny] == '.'){
                        uf.unite(x * n + y, nx * n + ny);
                    }
                }
            }
            vector<int> panel_state(n * 2);
            rep(i, n){
                panel_state[i] = uf.find(i * n);
                panel_state[i + n] = uf.find(i * n + n - 1);
            }
            normalize(panel_state);

            if(new_panel == 0){
                bool connected = false;
                rep(i, n)if(panel_state[i + n] < n){
                    if(ps[new_panel][panel_state[i + n]][0] == '.') connected = true;
                    break;
                }
                if(connected) new_states.insert(panel_state);
                rot(ps[new_panel]);
                continue;
            }

            UF uf2(n * 4);
            for(auto &prev_state: prev_states){
                uf2.clear();
                rep(i, n * 2) uf2.unite(i, prev_state[i]);
                rep(i, n) uf2.unite(i + n, i + 2 * n);
                rep(i, n * 2) uf2.unite(i + 2 * n, panel_state[i] + 2 * n);
                vector<int> new_state(n * 2);
                rep(i, n){
                    new_state[i] = uf2.find(i);
                    new_state[i + n] = uf2.find(i + 3 * n);
                }
                normalize(new_state);
                bool connected = false;
                rep(i, n)if(new_state[i + n] < n){
                    if(ps[new_panel][panel_state[i + n]][0] == '.') connected = true;
                    break;
                }
                if(connected) new_states.insert(new_state);
            }

            rot(ps[new_panel]);
        }
        swap(prev_states, new_states);
        new_states.clear();
    }
    puts(!prev_states.empty() ? "Yes" : "No");
}

int main(){
    while(scanf("%d%d", &n, &m) && n){
        solve();
    }
}


Measured memory_bytes: 4024