Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture.

Consider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and the robot can change a 'dirty tile' to a 'clean tile' by visiting the tile. Also there may be some obstacles (furniture) whose size fits a tile in the room. If there is an obstacle on a tile, the robot cannot visit it. The robot moves to an adjacent tile with one move. The tile onto which the robot moves must be one of four tiles (i.e., east, west, north or south) adjacent to the tile where the robot is present. The robot may visit a tile twice or more.

Your task is to write a program which computes the minimum number of moves for the robot to change all 'dirty tiles' to 'clean tiles', if ever possible.



Input

The input consists of multiple maps, each representing the size and arrangement of the room. A map is given in the following format.

> w h
>  c11 c12 c13 ... c1w
>  c21 c22 c23 ... c2w
>  ...
>  ch1 ch2 ch3 ... chw
>

The integers w and h are the lengths of the two sides of the floor of the room in terms of widths of floor tiles. w and h are less than or equal to 20. The character cyx represents what is initially on the tile with coordinates (x, y) as follows.

> '`.`' : a clean tile
>  '`*`' : a dirty tile
>  '`x`' : a piece of furniture (obstacle)
>  '`o`' : the robot (initial position)
>

In the map the number of 'dirty tiles' does not exceed 10. There is only one 'robot'.

The end of the input is indicated by a line containing two zeros.

Output

For each map, your program should output a line containing the minimum number of moves. If the map includes 'dirty tiles' which the robot cannot reach, your program should output -1.

Example

Input

7 5
.......
.o...*.
.......
.*...*.
.......
15 13
.......x.......
...o...x....*..
.......x.......
.......x.......
.......x.......
...............
xxxxx.....xxxxx
...............
.......x.......
.......x.......
.......x.......
..*....x....*..
.......x.......
10 10
..........
..o.......
..........
..........
..........
.....xxxxx
.....x....
.....x.*..
.....x....
.....x....
0 0


Output

8
49
-1
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
using namespace std;
struct st{
  int x,y,m,c;
  st(int x,int y,int m,int c) : x(x),y(y),m(m),c(c) {}
};
int W,H;
char fie[21][21];
int gomi[21][21];
int memo[21][21][(1<<10)];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int bit_max;
int solve(int x,int y){
  queue<st> q;
  while(!q.empty()) q.pop();
  q.push(st(x,y,0,0));
  memo[x][y][0]=0;
  while(!q.empty()){
    st p = q.front(); q.pop();
    x = p.x; y = p.y;
    for(int i=0;i<4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(nx < 0 || ny < 0 || nx>=W || ny>=H) continue;
      if(fie[nx][ny]=='x') continue;
      if(fie[nx][ny]=='*'){
	if( !((1<<gomi[nx][ny]) & p.m) ){
	  int next_m = ((1<<gomi[nx][ny]) | p.m);
	  if(memo[nx][ny][next_m]!=-1) continue;
	  if(bit_max == next_m) return p.c+1;
	  memo[nx][ny][next_m]=p.c+1;
	  q.push(st(nx,ny,next_m,p.c+1));
	}else{
	  if(memo[nx][ny][p.m]!=-1) continue;
	  memo[nx][ny][p.m]=p.c+1;
	  q.push(st(nx,ny,p.m,p.c+1));
	}
      }else{
	if(memo[nx][ny][p.m]!=-1) continue;
	memo[nx][ny][p.m]=p.c+1;
	q.push(st(nx,ny,p.m,p.c+1));
      }
    }
  }
  return -1;
}
int main(){
  while(1){
    int sx,sy;
    memset(memo,-1,sizeof(memo));
    memset(gomi,-1,sizeof(gomi));
    cin >> W >> H;
    if(!W && !H) break;
    int co=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
	if(fie[j][i]=='o'){
	  sx=j; sy=i;
	} else if(fie[j][i]=='*'){
	  gomi[j][i]=co;
	  ++co;
	}
      }
    }
    bit_max = (1<<co)-1;
    //    cout << bitset<16>(bit_max) << "\n";
    if(bit_max==0) cout << 0 << "\n";
    else cout << solve(sx,sy) << "\n";
  }
}