Apple adventure

square1001 and E869120 got lost in the grid world of $ H $ rows and $ W $ rows!

Said the god of this world.

"When you collect $ K $ apples and they meet, you'll be back in the original world."

Upon hearing this word, square1001 decided to collect more than $ K $ of apples and head to the square where E869120 is.




Here, each cell in the grid is represented as follows.

's': square1001 This is the square where you are.

'e': E869120 This is the square where you are.

'a': A square with one apple on it. You can get an apple the first time you visit this trout. There are no more than 20 squares on this grid.

'#': It's a wall. You cannot visit this square.

'.': A square with nothing. You can visit this square.




square1001 You try to achieve your goal by repeatedly moving from the square you are in to the squares that are adjacent to each other up, down, left, and right. However, you cannot get out of the grid.

square1001 Find the minimum number of moves you need to achieve your goal.

However, it is assumed that E869120 will not move. Also, square1001 shall be capable of carrying $ K $ or more of apples.

If the goal cannot be achieved, output "-1".

input

Input is given from standard input in the following format.

Let $ A_ {i, j} $ be the characters in the $ i $ square from the top of the grid and the $ j $ square from the left.


$ H $ $ W $ $ K $
$ A_ {1,1} A_ {1,2} A_ {1,3} \ cdots A_ {1, W} $
$ A_ {2,1} A_ {2,2} A_ {2,3} \ cdots A_ {2, W} $
$ A_ {3,1} A_ {3,2} A_ {3,3} \ cdots A_ {3, W} $
$ \ ldots $
$ A_ {H, 1} A_ {H, 2} A_ {H, 3} \ cdots A_ {H, W} $


output

square1001 Find the minimum number of moves you need to reach your goal. However, if this is not possible, output "-1".

However, insert a line break at the end.

Constraint

* $ 1 \ leq H \ leq 1000 $
* $ 1 \ leq W \ leq 1000 $
* $ 1 \ leq K \ leq 20 $
* $ H, W, K $ are integers.
* $ A_ {i, j} $ is one of's','e','a','#','.'.
* The grid contains only one's' and one'e'.
* The number of'a'in the grid is greater than or equal to $ K $ and less than or equal to $ 20 $.



Input example 1


5 5 2
s .. # a
. # ...
a # e. #
... # a
. # ...


Output example 1


14


Input example 2


7 7 3
.......
.s ... a.
a ## ... a
.. ### ..
.a # e # .a
. ### ..
a .. # .. a


Output example 2


-1


If the purpose cannot be achieved, output "-1".

Input example 3


12 12 10
. ##### ......
.## ..... # ...
.... a.a # a .. #
. # .. # a ......
..... a # s ..
..a ###. ##. #
.e #. #. #. # A ..
.. # a # ..... #.
.. ## a ......
.a ... a.a .. #.
a .... # a.aa ..
... a. # ... # a.


Output example 3


30






Example

Input

5 5 2
s..#a
.#...
a#e.#
...#a
.#...


Output

14
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 1005

struct LOC{
	void set(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

struct Info{
	Info(int arg_row,int arg_col,int arg_sum_dist){
		row = arg_row;
		col = arg_col;
		sum_dist = arg_sum_dist;
	}
	int row,col,sum_dist;
};

int H,W,K;
int start = 0,goal = 1;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
int work[SIZE][SIZE];
int min_dist[25][25],POW[25];
int dp[20][1 << 20];
char table[SIZE][SIZE];
LOC loc[25];


bool rangeCheck(int row,int col){

	return row >= 0 && row <= H-1 && col >= 0 && col <= W-1;
}


int main(){

	POW[0] = 1;
	for(int i = 1; i < 25; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d %d",&H,&W,&K);

	int index = 2;

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);
		for(int col = 0; col < W; col++){
			switch(table[row][col]){
			case 's':
				loc[start].set(row,col);
				break;

			case 'e':
				loc[goal].set(row,col);
				break;

			case 'a':
				loc[index].set(row,col);
				index++;
				break;

			default:
				//Do nothing
				break;
			}
		}
	}

	queue<Info> Q;

	for(int start = 0; start < index; start++){

		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){
				work[row][col] = BIG_NUM;
			}
		}

		work[loc[start].row][loc[start].col] = 0;
		Q.push(Info(loc[start].row,loc[start].col,0));

		while(!Q.empty()){

			if(Q.front().sum_dist > work[Q.front().row][Q.front().col]){

				Q.pop();

			}else{

				for(int i = 0; i < 4; i++){

					int adj_row = Q.front().row+diff_row[i];
					int adj_col = Q.front().col+diff_col[i];
					int next_dist = Q.front().sum_dist+1;

					if(rangeCheck(adj_row,adj_col) == false || table[adj_row][adj_col] == '#' ||
							work[adj_row][adj_col] <= next_dist)continue;

					work[adj_row][adj_col] = next_dist;
					Q.push(Info(adj_row,adj_col,next_dist));
				}

				Q.pop();
			}
		}

		for(int next = 0; next < index; next++){

			min_dist[start][next] = work[loc[next].row][loc[next].col];
		}
	}

	int ans = BIG_NUM;
	int num_apple = index-2,offset=2;

	for(int i = 0; i < num_apple; i++){
		for(int state = 0; state < POW[num_apple]; state++){
			dp[i][state] = BIG_NUM; //dp[最後のリンゴ][状態] = 最小コスト
		}
	}

	for(int i = 0; i < num_apple; i++){

		dp[i][POW[i]] = min_dist[start][i+offset];
	}

	int tmp;

	for(int state = 1; state < POW[num_apple]; state++){
		for(int i = 0; i < num_apple; i++){
			if(dp[i][state] == BIG_NUM)continue;

			tmp = 0;
			for(int loop = 0; loop < num_apple; loop++){
				if(state & (1 << loop))tmp++;
			}

			if(tmp == K){

				ans = min(ans,dp[i][state]+min_dist[i+offset][goal]);
				continue; //寄り道するのは無駄なので以後遷移は不要
			}

			for(int loop = 0; loop < num_apple; loop++){
				if(state & (1 << loop)){

					//Do nothing

				}else{
					int next_state = state+POW[loop];
					int next_dist = dp[i][state]+min_dist[i+offset][loop+offset];

					dp[loop][next_state] = min(dp[loop][next_state],next_dist);
				}
			}
		}
	}


	if(ans == BIG_NUM){

		printf("-1\n");
	}else{

		printf("%d\n",ans);
	}

	return 0;
}

