#include <bits/stdc++.h>
using namespace std;

struct status {
    int x, y;
    int dist;

    status() {}
    ~status() {}

    status(int a, int b): x(a), y(b) {}
    status(int a, int b, int c): x(a), y(b), dist(c) {}
};

struct point {
    int x, y;

    point() {}
    ~point() {}

    point(int a, int b): x(a), y(b) {}
    point(status s): x(s.x), y(s.y) {}

    bool operator < (const point& o) const {
        return x == o.x ? y < o.y : x < o.x;
    }
};

const int INF = 1 << 29;

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

int bit_count(int x) {
    int ret = 0;
    while(x > 0) {
        ret += x % 2;
        x >>= 1;
    }
    return ret;
}

bool solve() {
    int w; // 1 <= w <= 20
    int h; // 1 <= h <= 20
    cin >> w >> h;

    if (w == 0 && h == 0) {
        return false;
    }

    vector<string> c(h);
    
    for (int j = 0; j < h; ++j) {
        cin >> c[j];
    }

    map<point, int> ind;
    int N = 1;

    for (int j = 0; j < h; ++j) {
        for (int k = 0; k < w; ++k) {
            if (c[j][k] == '*') {
                ind[point(j, k)] = N++;
            }
            if (c[j][k] == 'o') {
                ind[point(j, k)] = 0;
            }
        }
    }

    vector<vector<int>> g(N, vector<int>(N, INF));
    for (int j = 0; j < N; ++j) {
        g[j][j] = 0;
    }

    for (auto& pp : ind) {
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<status> que;

        point start = pp.first;
        int num = pp.second;

        que.push(status(start.x, start.y, 0));
        dist[start.x][start.y] = 0;

        while (!que.empty()) {
            status st = que.front(); que.pop();
            
            if (dist[st.x][st.y] < st.dist) {
                continue;
            }

            if (c[st.x][st.y] == '*' || c[st.x][st.y] == 'o') {
                g[num][ind[point(st)]] = st.dist;
                g[ind[point(st)]][num] = st.dist;
            }

            for (int j = 0; j < 4; ++j) {
                int nx = st.x + dx[j];
                int ny = st.y + dy[j];
                
                if (nx < 0 || h <= nx) continue;
                if (ny < 0 || w <= ny) continue;
                if (c[nx][ny] == 'x') continue;

                if (dist[nx][ny] > st.dist + 1) {
                    dist[nx][ny] = st.dist + 1;
                    
                    que.push(status(nx, ny, dist[nx][ny]));
                }
            }
        }
    }

    // for (int j = 0; j < N; ++j) {
    //     for (int k = 0; k < N ; ++k) {
    //         cout << g[j][k] << " ";
    //     }
    //     cout << endl;
    // }

    vector<vector<int>> dp(1 << N, vector<int>(N, INF));
    dp[1][0] = 0;

    for (int b = 1; b < N; ++b) {
        for (int j = 0; j < (1 << N); ++j) {
            if(bit_count(j) != b) continue;

            for (int k = 0; k < N; ++k) {
                if ((j & (1 << k)) == 0) {
                    int nj = j | (1 << k);

                    for (int l = 0; l < N; ++l) {
                        dp[nj][k] = min(dp[nj][k], dp[j][l] + g[k][l]);
                    }
                }
            }
        }
    }

    int ret = INF;
    for (int j = 0; j < N; ++j) {
        ret = min(ret, dp[(1 << N) - 1][j]);
    }

    // for (int j = 0; j < (1 << N); ++j) {
    //     for (int k = 0; k < N; ++k) {
    //         cout << dp[j][k] << " ";
    //     }
    //     cout << endl;
    // }

    if (ret == INF) {
        cout << "-1" << endl;
    } else {
        cout << ret << endl;
    }

    return true;
}


int main () {
    while(solve());
    return 0;
}

Measured memory_bytes: 1308