#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
int di[6][3] = {{0,1,0},{1,0,0},{0,-1,0},{-1,0,0},{0,0,1},{0,0,-1}};
struct Node{
    int x,y,z;
    Node(){}
    Node(int _x,int _y,int _z):x(_x),y(_y),z(_z){}
};

queue<Node>Q;
int a[11][11][11];
char map[11][11];
int k,m,n,sx,sy;

int BFS(Node s){
    while(!Q.empty())Q.pop();
    Q.push(s);
    a[s.x][s.y][s.z] = 1;
    int res = 0;
    while(!Q.empty()){
        res ++;
        Node tmp = Q.front();
        Q.pop();
        int tz,tx,ty;
        for(int w = 0; w < 6; ++w){
            tx = tmp.x + di[w][0];
            ty = tmp.y + di[w][1];
            tz = tmp.z + di[w][2];
            if(tx > m || tx < 1 || ty > n || ty < 1 || tz > k || tz < 1)continue;
            if(a[tx][ty][tz] == 0){
                Q.push(Node(tx,ty,tz));
                a[tx][ty][tz] = 1;
            }
        }
    }
    return res;
}

int main(){
    scanf("%d%d%d",&k,&m,&n);
    memset(a,0,sizeof(a));
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= m; ++j){
            scanf(" %s",map[j]+1);
            for(int t = 1; t <= n; ++t){
                if(map[j][t] != '.')//a[j][t][i] = 0;
                 a[j][t][i] = 1;
            }
        }
    }
    scanf("%d%d",&sx,&sy);
    int ans = BFS(Node(sx,sy,1));
    printf("%d\n",ans);

}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
using namespace std ;

//Seniores yo soy el chosto y tengo aguante
//Yo sigo a mis chostitos a todas partes

struct coor {
    int piso, ren, col ;
    coor() {
    }
    coor( int A, int B, int C ) {
        piso = A;
        ren = B ;
        col = C ;
    }
};

int main() {
    int K, N, M ;
    char mapa[20][20][20] ;
    coor pos, pos2 ;
    queue <coor> q ;
    int dr[] = { -1, 0, 1, 0, 0, 0 } ;
    int dc[] = {  0, 1, 0, -1, 0, 0 } ;
    int dp[] = { 0, 0, 0, 0, -1, 1 } ;
    int p, r, c, d ;
    int res = 0 ;

    scanf("%d%d%d",&K,&N,&M ) ;
    for( p=0; p<K; p++ ) {
        for( r=0; r<N; r++ ) {
            scanf("%s",mapa[p][r] ) ;
        }
    }
    pos.piso = 0 ;
    scanf("%d%d",&pos.ren,&pos.col ) ;

    pos.ren -- , pos.col -- ;
    mapa[pos.piso][pos.ren][pos.col] = '#' ;
    q.push(pos) ;
    while( !q.empty()  )  {
        res ++ ;
        pos = q.front() ;
        q.pop() ;
        for( d=0; d<6; d++ ) {
            pos2 = pos ;
            pos2.ren += dr[d] ;
            pos2.col += dc[d] ;
            pos2.piso += dp[d] ;
            if( pos2.ren >= N || pos2.ren < 0   )
                continue ;
            if( pos2.col >= M || pos2.col< 0   )
                continue ;
            if( pos2.piso >= K || pos2.piso < 0   )
                continue ;
            if( mapa[pos2.piso][ pos2.ren ][ pos2.col ] == '#' )
                continue ;
            mapa[pos2.piso][pos2.ren][pos2.col] = '#' ;
            q.push( pos2 ) ;
        }
    }

    printf("%d\n",res ) ;

    return 0 ;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
using namespace std ;

struct coor {
    int piso, ren, col ;
    coor() {
    }
    coor( int A, int B, int C ) {
        piso = A;
        ren = B ;
        col = C ;
    }
};

int main() {
    int K, N, M ;
    char mapa[20][20][20] ;
    coor pos, pos2 ;
    queue <coor> q ;
    int dr[] = { -1, 0, 1, 0, 0, 0 } ;
    int dc[] = {  0, 1, 0, -1, 0, 0 } ;
    int dp[] = { 0, 0, 0, 0, -1, 1 } ;
    int p, r, c, d ;
    int res = 0 ;

    scanf("%d%d%d",&K,&N,&M ) ;
    for( p=0; p<K; p++ ) {
        for( r=0; r<N; r++ ) {
            scanf("%s",mapa[p][r] ) ;
        }
    }
    pos.piso = 0 ;
    scanf("%d%d",&pos.ren,&pos.col ) ;

    pos.ren -- , pos.col -- ;
    mapa[pos.piso][pos.ren][pos.col] = '#' ;
    q.push(pos) ;
    while( !q.empty()  )  {
        res ++ ;
        pos = q.front() ;
        q.pop() ;
        for( d=0; d<6; d++ ) {
            pos2 = pos ;
            pos2.ren += dr[d] ;
            pos2.col += dc[d] ;
            pos2.piso += dp[d] ;
            if( pos2.ren >= N || pos2.ren < 0   )
                continue ;
            if( pos2.col >= M || pos2.col< 0   )
                continue ;
            if( pos2.piso >= K || pos2.piso < 0   )
                continue ;
            if( mapa[pos2.piso][ pos2.ren ][ pos2.col ] == '#' )
                continue ;
            mapa[pos2.piso][pos2.ren][pos2.col] = '#' ;
            q.push( pos2 ) ;
        }
    }

    printf("%d\n",res ) ;

    return 0 ;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
using namespace std ;

//Seniores yo soy el chosto y tengo aguante

struct coor {
    int piso, ren, col ;
    coor() {
    }
    coor( int A, int B, int C ) {
        piso = A;
        ren = B ;
        col = C ;
    }
};

int main() {
    int K, N, M ;
    char mapa[20][20][20] ;
    coor pos, pos2 ;
    queue <coor> q ;
    int dr[] = { -1, 0, 1, 0, 0, 0 } ;
    int dc[] = {  0, 1, 0, -1, 0, 0 } ;
    int dp[] = { 0, 0, 0, 0, -1, 1 } ;
    int p, r, c, d ;
    int res = 0 ;

    scanf("%d%d%d",&K,&N,&M ) ;
    for( p=0; p<K; p++ ) {
        for( r=0; r<N; r++ ) {
            scanf("%s",mapa[p][r] ) ;
        }
    }
    pos.piso = 0 ;
    scanf("%d%d",&pos.ren,&pos.col ) ;

    pos.ren -- , pos.col -- ;
    mapa[pos.piso][pos.ren][pos.col] = '#' ;
    q.push(pos) ;
    while( !q.empty()  )  {
        res ++ ;
        pos = q.front() ;
        q.pop() ;
        for( d=0; d<6; d++ ) {
            pos2 = pos ;
            pos2.ren += dr[d] ;
            pos2.col += dc[d] ;
            pos2.piso += dp[d] ;
            if( pos2.ren >= N || pos2.ren < 0   )
                continue ;
            if( pos2.col >= M || pos2.col< 0   )
                continue ;
            if( pos2.piso >= K || pos2.piso < 0   )
                continue ;
            if( mapa[pos2.piso][ pos2.ren ][ pos2.col ] == '#' )
                continue ;
            mapa[pos2.piso][pos2.ren][pos2.col] = '#' ;
            q.push( pos2 ) ;
        }
    }

    printf("%d\n",res ) ;

    return 0 ;
}


// Kim Vyacheslav
// 2011
#include <cstdio>
#include <iostream>

#include <cmath>
#include <cstring>
#include <algorithm>

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <sstream>

using namespace std;

#define min(a,b) (a<b?a:b)
#define max(a,b) (a<b?b:a)
#define all(x) (x.begin(),x.end())
#define pb push_back
#define sqr(x) (x)*(x)

#define dbg(x) cout<<#x<<" = "<<x<<" "
#define forn(i,n) for(int i = 0; i < n; i++)
#define ford(i,n) for(int i = n - 1; i >= 0; i--)
const int inf = 1 << 30;
#define X to.x
#define Y to.y
#define Z to.z
struct cl
{
    int x, y, z;
};
const int maxn = 200;
long n, m, k, sx, sy, ans;
long d[] = {0,0,1, 0,0,-1, 0,1,0, 0,-1,0, 1,0,0, -1,0,0};
bool u[maxn][maxn][maxn];
char can[maxn][maxn][maxn];
queue<cl>q;

int main ()
{
    scanf ("%ld%ld%ld", &n, &m, &k);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf ("%s", can[i][j]);
    scanf ("%ld%ld", &sx, &sy);
    cl start, cur, to;
    start.y = sx - 1;
    start.z = sy - 1;
    start.x = 0;
    u[0][sx-1][sy-1] = 1;
    q.push(start);
    while (!q.empty())
    {
        cur = q.front();
        q.pop();
        if (can[cur.x][cur.y][cur.z] != '.')
            continue;
        ans++;
//        printf("%ld %ld %ld\n", cur.x,cur.y,cur.z);
        for (int i = 0; i < 18; i += 3)
        {
            to = cur;
            to.x += d[i];
            to.y += d[i + 1];
            to.z += d[i + 2];
            if (0 <= X < n &&
                0 <= Y < m &&
                0 <= Z < k && !u[X][Y][Z] && can[X][Y][Z] == '.')
            {
                u[X][Y][Z] = 1;
                q.push(to);
            }
        }
    }
    printf("%ld\n", ans);
    return 0;
}


// Kim Vyacheslav
// 2011
#include <cstdio>
#include <iostream>

#include <cmath>
#include <cstring>
#include <algorithm>

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <sstream>

using namespace std;

#define min(a,b) (a<b?a:b)
#define max(a,b) (a<b?b:a)
#define all(x) (x.begin(),x.end())
#define pb push_back
#define sqr(x) (x)*(x)

#define dbg(x) cout<<#x<<" = "<<x<<" "
#define forn(i,n) for(int i = 0; i < n; i++)
#define ford(i,n) for(int i = n - 1; i >= 0; i--)
const int inf = 1 << 30;
#define X to.x
#define Y to.y
#define Z to.z
struct cl
{
    int x, y, z;
};
int n, m, k, sx, sy, ans;
int d[] = {0,0,1, 0,0,-1, 0,1,0, 0,-1,0, 1,0,0, -1,0,0};
bool a[100][100][100], u[100][100][100];
char can[100][100][100];
queue<cl>q;

int main ()
{
    freopen("input.txt", "r", stdin);
    scanf ("%d%d%d", &n, &m, &k);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf ("%s", can[i][j]);
    scanf ("%d%d", &sx, &sy);
    cl start, cur, to;
    start.y = sx - 1;
    start.z = sy - 1;
    start.x = 0;
    u[0][sx-1][sy-1] = 1;
    q.push(start);
    while (!q.empty())
    {
        cur = q.front();
        q.pop();
        ans++;
//        printf("%d %d %d\n", cur.x,cur.y,cur.z);
        for (int i = 0; i < 18; i += 3)
        {
            to = cur;
            to.x += d[i];
            to.y += d[i + 1];
            to.z += d[i + 2];
            if (0 <= X < n &&
                0 <= Y < m &&
                0 <= Z < k && !u[X][Y][Z] && can[X][Y][Z] == '.')
            {
                u[X][Y][Z] = 1;
                q.push(to);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


// Kim Vyacheslav
// 2011
#include <cstdio>
#include <iostream>

#include <cmath>
#include <cstring>
#include <algorithm>

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <sstream>

using namespace std;

#define min(a,b) (a<b?a:b)
#define max(a,b) (a<b?b:a)
#define all(x) (x.begin(),x.end())
#define pb push_back
#define sqr(x) (x)*(x)

#define dbg(x) cout<<#x<<" = "<<x<<" "
#define forn(i,n) for(int i = 0; i < n; i++)
#define ford(i,n) for(int i = n - 1; i >= 0; i--)
const int inf = 1 << 30;
#define X to.x
#define Y to.y
#define Z to.z
struct cl
{
    int x, y, z;
};
int n, m, k, sx, sy, ans;
int d[] = {0,0,1, 0,0,-1, 0,1,0, 0,-1,0, 1,0,0, -1,0,0};
bool a[100][100][100], u[100][100][100];
char can[100][100][100];
queue<cl>q;

int main ()
{
    scanf ("%d%d%d", &n, &m, &k);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf ("%s", can[i][j]);
    scanf ("%d%d", &sx, &sy);
    cl start, cur, to;
    start.y = sx - 1;
    start.z = sy - 1;
    start.x = 0;
    u[0][sx-1][sy-1] = 1;
    q.push(start);
    while (!q.empty())
    {
        cur = q.front();
        q.pop();
        ans++;
//        printf("%d %d %d\n", cur.x,cur.y,cur.z);
        for (int i = 0; i < 18; i += 3)
        {
            to = cur;
            to.x += d[i];
            to.y += d[i + 1];
            to.z += d[i + 2];
            if (0 <= X < n &&
                0 <= Y < m &&
                0 <= Z < k && !u[X][Y][Z] && can[X][Y][Z] == '.')
            {
                u[X][Y][Z] = 1;
                q.push(to);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


// Kim Vyacheslav
// 2011
#include <cstdio>
#include <iostream>

#include <cmath>
#include <cstring>
#include <algorithm>

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <sstream>

using namespace std;

#define min(a,b) (a<b?a:b)
#define max(a,b) (a<b?b:a)
#define all(x) (x.begin(),x.end())
#define pb push_back
#define sqr(x) (x)*(x)

#define dbg(x) cout<<#x<<" = "<<x<<" "
#define forn(i,n) for(int i = 0; i < n; i++)
#define ford(i,n) for(int i = n - 1; i >= 0; i--)
const int inf = 1 << 30;
#define X to.x
#define Y to.y
#define Z to.z
struct cl
{
    int x, y, z;
};
const int maxn = 200;
long n, m, k, sx, sy, ans;
long d[] = {0,0,1, 0,0,-1, 0,1,0, 0,-1,0, 1,0,0, -1,0,0};
bool u[maxn][maxn][maxn];
char can[maxn][maxn][maxn];
queue<cl>q;

int main ()
{
    scanf ("%ld%ld%ld", &n, &m, &k);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf ("%s", can[i][j]);
    scanf ("%ld%ld", &sx, &sy);
    cl start, cur, to;
    start.y = sx - 1;
    start.z = sy - 1;
    start.x = 0;
    u[0][sx-1][sy-1] = 1;
    q.push(start);
    while (!q.empty())
    {
        cur = q.front();
        q.pop();
        if (can[cur.x][cur.y][cur.z] != '.')
            continue;
        ans++;
//        printf("%ld %ld %ld\n", cur.x,cur.y,cur.z);
        for (int i = 0; i < 18; i += 3)
        {
            to = cur;
            to.x += d[i];
            to.y += d[i + 1];
            to.z += d[i + 2];
            if (0 <= X && X < n &&
                0 <= Y && Y < m &&
                0 <= Z && Z < k && !u[X][Y][Z] && can[X][Y][Z] == '.')
            {
                u[X][Y][Z] = 1;
                q.push(to);
            }
        }
    }
    printf("%ld\n", ans);
    return 0;
}


// Kim Vyacheslav
// 2011
#include <cstdio>
#include <iostream>

#include <cmath>
#include <cstring>
#include <algorithm>

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <sstream>

using namespace std;

#define min(a,b) (a<b?a:b)
#define max(a,b) (a<b?b:a)
#define all(x) (x.begin(),x.end())
#define pb push_back
#define sqr(x) (x)*(x)

#define dbg(x) cout<<#x<<" = "<<x<<" "
#define forn(i,n) for(int i = 0; i < n; i++)
#define ford(i,n) for(int i = n - 1; i >= 0; i--)
const int inf = 1 << 30;
#define X to.x
#define Y to.y
#define Z to.z
struct cl
{
    int x, y, z;
};
int n, m, k, sx, sy, ans;
int d[] = {0,0,1, 0,0,-1, 0,1,0, 0,-1,0, 1,0,0, -1,0,0};
bool a[100][100][100], u[100][100][100];
char can[100][100][100];
queue<cl>q;

int main ()
{
    scanf ("%d%d%d", &n, &m, &k);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf ("%s", can[i][j]);
    scanf ("%d%d", &sx, &sy);
    cl start, cur, to;
    start.y = sx - 1;
    start.z = sy - 1;
    start.x = 0;
    u[0][sx-1][sy-1] = 1;
    q.push(start);
    while (!q.empty())
    {
        cur = q.front();
        q.pop();
        if (can[cur.x][cur.y][cur.z] != '.')
            continue;
        ans++;
//        printf("%d %d %d\n", cur.x,cur.y,cur.z);
        for (int i = 0; i < 18; i += 3)
        {
            to = cur;
            to.x += d[i];
            to.y += d[i + 1];
            to.z += d[i + 2];
            if (0 <= X < n &&
                0 <= Y < m &&
                0 <= Z < k && !u[X][Y][Z] && can[X][Y][Z] == '.')
            {
                u[X][Y][Z] = 1;
                q.push(to);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <iostream>

using namespace std;

int k, n, m, X, Y;
bool F[16][16][16];
int ans=0;

void dfs(int x, int y, int z)
{
        if (F[x][y][z]) return;
        F[x][y][z] = true;
        ans++;

        dfs(x+1,y,z);
        dfs(x-1,y,z);
        dfs(x,y+1,z);
        dfs(x,y-1,z);
        dfs(x,y,z+1);
        dfs(x,y,z-1);
}

void sol()
{
        dfs(1,X,Y);
        cout << ans;
}

int main()
{
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin >> k >> n >> m;

        char Ch[32];
        for(int a = 1; a <= k; a++)
        for(int b = 1; b <= n; b++)
        {
                scanf("%s", Ch);
                for(int c = 1; c <= m; c++) if (Ch[c-1]=='#') F[a][b][c] = true;
        }
        for(int a = 0; a <= k+1; a++)
                for(int b = 0; b <= n+1; b++)
                                for(int c = 0; c <= m+1; c++)
                if (a==0 || a==k+1 || b==0 || b==n+1 || c==0 || c==m+1)
                        F[a][b][c] = true;

        cin >> X >> Y;

        sol();
        return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

int k, n, m, X, Y;
bool F[16][16][16];
int ans=0;

void dfs(int x, int y, int z)
{
        if (F[x][y][z]) return;
        F[x][y][z] = true;
        ans++;

        dfs(x+1,y,z);
        dfs(x-1,y,z);
        dfs(x,y+1,z);
        dfs(x,y-1,z);
        dfs(x,y,z+1);
        dfs(x,y,z-1);
}

void sol()
{
        dfs(1,X,Y);
        cout << ans;
}

int main()
{
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin >> k >> n >> m;

        char Ch[32];
        for(int a = 1; a <= k; a++)
        for(int b = 1; b <= n; b++)
        {
                scanf("%s", Ch);
                for(int c = 1; c <= m; c++) if (Ch[c-1]=='#') F[a][b][c] = true;
        }
        for(int a = 0; a <= k+1; a++)
                for(int b = 0; b <= n+1; b++)
                                for(int c = 0; c <= m+1; c++)
                if (a==0 || a==k+1 || b==0 || b==n+1 || c==0 || c==m+1)
                        F[a][b][c] = true;

        cin >> X >> Y;

        sol();
        return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

bool F[15][15][15];
int ans = 0;

void DFS(int x, int y, int z)
{
    if(F[x][y][z])
        return;
    F[x][y][z] = true;
    ans++;

    DFS(x+1, y, z);
    DFS(x-1, y, z);
    DFS(x, y+1, z);
    DFS(x, y-1, z);
    DFS(x, y, z+1);
    DFS(x, y, z-1);
}

int main()
{
    int k,m,n,X,Y,i,j,p;
    char plat[12];

    cin >> k >> n >> m;
    for(i = 1; i <= k; i++)
        for(j = 1; j <= n; j++)
        {
            scanf("%s",plat);
            for(p = 1; p <= m; p++)
            {
                if(plat[p-1] == '#')
                    F[i][j][p] = true;
            }
        }
    for(i = 0; i <= k+1; i++)
        for(j = 0; j <= n+1; j++)
            for(p = 0; p <= m+1; p++)
            {
                if(i == 0 || i == k+1 || j == 0 || j == n+1 || p == 0 || p == m+1)
                    F[i][j][p] = true;
            }

    scanf("%d %d",&X,&Y);
    DFS(1,X,Y);

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


#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;
int D,R,C,st_r,st_c,dd[]={-1,1,0,0,0,0},dr[]={0,0,0,0,1,-1},dc[]={0,0,1,-1,0,0};
char s[15][15][15];
bool vis[15][15][15];
bool available (int d, int r, int c)
{
    if (d<0 || r<0 || c<0 || d==D || r==R || c==C || s[d][r][c]=='#' || vis[d][r][c])
        return 0;
    return 1;
}
int flood (int d, int r, int c)
{
    int ret =1;
    vis[d][r][c] = 1;
    for (int i=0; i<6; i++)
    {
        int next_r = r + dr[i];
        int next_c = c + dc[i];
        int next_d = d + dd[i];
        if (available(next_d,next_r,next_c))
            ret += flood(next_d,next_r,next_c);
    }
    return ret;
}
int main()
{
    scanf("%d %d %d",&D,&R,&C);
    for (int k=0; k<D; k++)
        for (int i=0; i<R; i++)
                scanf("%s",s[k][i]);
    scanf("%d %d",&st_r,&st_c);
    cout << flood(0,st_r-1,st_c-1);

    return 0;
}


#include <iostream>
#include <queue>
using namespace std;

int K,N,M,X,Y;
char g[10][10][11];
int ret=0;

void flood(int x, int y, int z){
	if (x>=M||y>=N||z>=K||x<0||y<0||z<0) return;
	if (g[z][y][x] == '#') return;
	g[z][y][x] = '#';
	ret++;
	flood(x+1,y,z);
	flood(x,y+1,z);
	flood(x-1,y,z);
	flood(x,y-1,z);
	flood(x,y,z+1);
	flood(x,y,z-1);
}

int main(){
	cin >> K >> N >> M;
	for (int i = 0; i < K; i++){
		for (int j = 0; j < N; j++){
			cin >> g[i][j];
		}
	}
	cin >> Y >> X;
	flood(X-1, Y-1, 0);
	cout << ret << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;
struct edge {
    int n;
    long long c;
    edge (int _n, long long _c)
    {
        n = _n;
        c = _c;
    }
    bool operator < (const edge &e) const
    {
        return c > e.c;
    }
};
vector <edge> adj[100010];
vector <int> timeToWait[100010];
bool vis[100010];
int main()
{
    int N,M,f,t;
    long long c;
    long long dist[100010];
    memset(dist,63,sizeof dist);
    scanf("%d %d",&N,&M);
    for (int i=0; i<M; i++)
    {
        scanf("%d %d %I64d",&f,&t,&c);
        adj[f-1].push_back(edge(t-1,c));
        adj[t-1].push_back(edge(f-1,c));
    }
    for (int i=0; i<N; i++)
    {
        int SIZE;
        scanf("%d",&SIZE);
        timeToWait[i].resize(SIZE);
        for (int j=0; j<SIZE; j++)
            scanf("%d",&timeToWait[i][j]);
    }
    priority_queue <edge> q;
    q.push(edge(0,0));
    dist[0] = 0;
    long long ans = -1;
    while (!q.empty())
    {
        edge cur = q.top();
        q.pop();
        if (vis[cur.n]) continue;
        vis[cur.n] = 1;
        if (cur.n == N-1)
        {
            ans = dist[cur.n];
            break;
        }
        for (int i=0; i<adj[cur.n].size(); i++)
        {
            edge next = adj[cur.n][i];
            long long next_time = dist[cur.n]+next.c;
            int low = (int)(lower_bound(timeToWait[next.n].begin(),timeToWait[next.n].end(),next_time)-timeToWait[next.n].begin());
            while (low < timeToWait[next.n].size()) /// to be eliminated if TLE
            {
                if (timeToWait[next.n][low]!=next_time)
                    break;
                low++;
                next_time++;
            }
            if (dist[next.n] > next_time)
            {
                dist[next.n] = next.c = next_time;
                q.push(next);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;
struct edge {
    int n,c;
    edge (int _n, int _c)
    {
        n = _n;
        c = _c;
    }
    bool operator < (const edge &e) const
    {
        return c > e.c;
    }
};
vector <edge> adj[100010];
vector <int> timeToWait[100010];
bool vis[115];
int main()
{
    int N,M,f,t,c,dist[1000010];
    memset(dist,63,sizeof dist);
    scanf("%d %d",&N,&M);
    for (int i=0; i<M; i++)
    {
        scanf("%d %d %d",&f,&t,&c);
        adj[f-1].push_back(edge(t-1,c));
        adj[t-1].push_back(edge(f-1,c));
    }
    for (int i=0; i<N; i++)
    {
        int SIZE;
        scanf("%d",&SIZE);
        timeToWait[i].resize(SIZE);
        for (int j=0; j<SIZE; j++)
            scanf("%d",&timeToWait[i][j]);
    }
    priority_queue <edge> q;
    q.push(edge(0,0));
    dist[0] = 0;
    int ans = -1;
    while (!q.empty())
    {
        edge cur = q.top();
        q.pop();
        if (vis[cur.n]) continue;
        vis[cur.n] = 1;
        if (cur.n == N-1)
        {
            ans = dist[cur.n];
            break;
        }
        for (int i=0; i<adj[cur.n].size(); i++)
        {
            edge next = adj[cur.n][i];
            int next_time = dist[cur.n]+next.c;
            int low = (int)(lower_bound(timeToWait[next.n].begin(),timeToWait[next.n].end(),next_time)-timeToWait[next.n].begin());
            while (low < timeToWait[next.n].size()) /// to be eliminated if TLE
            {
                if (timeToWait[next.n][low]!=next_time)
                    break;
                low++;
                next_time++;
            }
            if (dist[next.n] > next_time)
            {
                dist[next.n] = next.c = next_time;
                q.push(next);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


/*OJ:
  ProblemID:
  Date:
*/

 #include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define mp make_pair
#define pb push_back
#define all(n) (n).begin,(n).end
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef vector<int> vi;
const int INF=1e9+7;
/*_____main part_____*/
int n,m,k;
int dx[6]={0,0,0,0,1,-1};
int dy[6]={1,-1,0,0,0,0};
int dz[6]={0,0,-1,1,0,0};
int ans;
bool used[55][55][55];
char a[55][55][55];
void dfs(int x,int y,int z)
{
	used[x][y][z]=true;
	if(a[x][y][z]=='#')
	return;
	ans++;
	for(int i=0;i<6;i++)
	{
		int tx=x+dx[i],ty=y+dy[i],tz=z+dz[i];
		if(!used[tx][ty][tz] and tx>0 and tx<=k and ty>0 and ty<=n and tz>0 and tz<=m)
		dfs(tx,ty,tz);
	}
}
int main()
{
	cin>>k>>n>>m;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int q=1;q<=m;q++)
			{
				cin>>a[i][j][q];
			}
		}
	}
	int N,M;
	cin>>N>>M;
	dfs(1,N,M);
	cout<<ans;
	return 0;
}


/*OJ:codeforces
  ProblemID:60B
  Date:2018.4.30
*/

 #include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define mp make_pair
#define pb push_back
#define all(n) (n).begin,(n).end
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef vector<int> vi;
const int INF=1e9+7;
/*_____main part_____*/
int n,m,k;
int dx[6]={0,0,0,0,1,-1};
int dy[6]={1,-1,0,0,0,0};
int dz[6]={0,0,-1,1,0,0};
int ans;
bool used[55][55][55];
char a[55][55][55];
void dfs(int x,int y,int z)
{
	used[x][y][z]=true;
	if(a[x][y][z]=='#')
	return;
	ans++;
	for(int i=0;i<6;i++)
	{
		int tx=x+dx[i],ty=y+dy[i],tz=z+dz[i];
		if(!used[tx][ty][tz] and tx>0 and tx<=k and ty>0 and ty<=n and tz>0 and tz<=m)
		dfs(tx,ty,tz);
	}
}
int main()
{
	cin>>k>>n>>m;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int q=1;q<=m;q++)
			{
				cin>>a[i][j][q];
			}
		}
	}
	int N,M;
	cin>>N>>M;
	dfs(1,N,M);
	cout<<ans;
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int visit[11][11][11];
char ch[11][11][11];
int dx[6]={1,-1,0,0,0,0};
int dy[6]={0,0,1,-1,0,0};
int dz[6]={0,0,0,0,1,-1};
	int n,m,k;
void dfs(int x,int y,int z)
{
	visit[x][y][z]=1;
	for(int i=0;i<6;i++)
	{
		int xx=x+dx[i];
		int yy=dy[i]+y;
		int zz=dz[i]+z;
		if(!xx||!yy||!zz||xx>n||yy>m||zz>k||ch[xx][yy][zz]=='#') continue;
		if(!visit[xx][yy][zz]) dfs(xx,yy,zz);
	}
}
int main()
{
	memset(visit,0,sizeof(visit));
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int o=1;o<=k;o++)
			{
				cin>>ch[i][j][o];
			}
		}
	}
	int x,y;
	cin>>x>>y;
	dfs(n,x,y);
	int ans=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)for(int o=1;o<=k;o++)if(visit[i][j][o])ans++;
	cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int visit[11][11][11];
char ch[11][11][11];
int dx[6]={1,-1,0,0,0,0};
int dy[6]={0,0,1,-1,0,0};
int dz[6]={0,0,0,0,1,-1};
	int n,m,k;
void dfs(int x,int y,int z)
{
	visit[x][y][z]=1;
	for(int i=0;i<6;i++)
	{
		int xx=x+dx[i];
		int yy=dy[i]+y;
		int zz=dz[i]+z;
		if(!xx||!yy||!zz||xx>n||yy>m||zz>k||ch[xx][yy][zz]=='#') continue;
		if(!visit[xx][yy][zz]) dfs(xx,yy,zz);
	}
}
int main()
{
	memset(visit,0,sizeof(visit));
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int o=1;o<=k;o++)
			{
				cin>>ch[i][j][o];
			}
		}
	}
	int x,y;
	cin>>x>>y;
	dfs(1,x,y);
	int ans=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)for(int o=1;o<=k;o++)if(visit[i][j][o])ans++;
	cout<<ans<<endl;
    return 0;
}


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

int n,m,k,ans=0;
char adj[102][12];
vector<vector <bool> > visited;
int dx[6]={0,0,1,-1,n,-n};
int dy[6]={1,-1,0,0,0,0};

bool valid(int a,int b,int x,int y){
    if((x>a&&a%n==0&&x%n!=0)||(x<a&&x%n==0&&a%n!=0)){
        return false;
    }

     return (x<=k*n&&x>0&&y<=m&&y>0);
}
int dfs(int x,int y){
    visited[x][y]=true;
    ans++;

    for(int i=0;i<6;i++){
        if(valid(x,y,x+dx[i],y+dy[i])&&adj[x+dx[i]][y+dy[i]]=='.'&&!visited[x+dx[i]][y+dy[i]])
            dfs(x+dx[i],y+dy[i]);
    }
    return ans;
}

int main()
{

    char c;
    int startX,startY;
    cin>>k>>n>>m;
    dx[4]=n;dx[5]=-1*n;
    visited=vector<vector <bool> >(k*n+1,vector<bool> (m+1, 0));
    for(int i=1;i<=n*k;i++){
        for(int j=1;j<=m;j++){
            cin>>c;
            adj[i][j]=c;

        }
    }

    cin>>startX>>startY;
    ans=dfs(startX,startY);
    cout<<ans;
    return 0;
}


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

int n,m,k,ans=0;
char adj[102][12];
vector<vector <bool> > visited;
int dx[6]={0,0,1,-1,n,-n};
int dy[6]={1,-1,0,0,0,0};

bool valid(int a,int b,int x,int y){
    if((x>a&&a%n==0&&x%n!=0)||(x<a&&x%n==0&&a%n!=0)){
        return false;
    }

     return (x<=k*n&&x>0&&y<=m&&y>0);
}
int dfs(int x,int y){
    visited[x][y]=true;
    ans++;

    for(int i=0;i<6;i++){
        if(valid(x,y,x+dx[i],y+dy[i])&&adj[x+dx[i]][y+dy[i]]=='.'&&!visited[x+dx[i]][y+dy[i]])
            dfs(x+dx[i],y+dy[i]);
    }
    return ans;
}

int main()
{
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    char c;
    int startX,startY;
    cin>>k>>n>>m;
    dx[4]=n;dx[5]=-1*n;
    visited=vector<vector <bool> >(k*n+1,vector<bool> (m+1, 0));
    for(int i=1;i<=n*k;i++){
        for(int j=1;j<=m;j++){
            cin>>c;
            adj[i][j]=c;

        }
    }

    cin>>startX>>startY;
    ans=dfs(startX,startY);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define pi pair<int,int>
#define pii pair<int,pi>
#define F first
#define S second
using namespace std;
int f,n,m;
int p[15][15][15];
int df[6]={1,-1,0,0,0,0};
int dx[6]={0,0,1,-1,0,0};
int dy[6]={0,0,0,0,1,-1};
char c;
void ch(int h,int x,int y)
{
	if(p[h][x][y]!=1)
	return;
	p[h][x][y]=2;
	for(int i=0;i<6;i++)
	ch(h+df[i],x+dx[i],y+dy[i]);
}
int main()
{
	cin>>f>>n>>m;
	for(int k=1;k<=f;k++)
	{
		for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>c;
			if(c=='#')
			p[k][i][j]=0;
			else
			p[k][i][j]=1;
		}
	}
	int bx,by;
	cin>>bx>>by;
	ch(1,bx,by);
	int ans=0;
	for(int i=1;i<=f;i++)
	for(int j=1;j<=n;j++)
	for(int k=1;k<=m;k++)
	if(p[i][j][k]==2)
	ans++;
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define pi pair<int,int>
#define pii pair<int,pi>
#define F first
#define S second
using namespace std;
int f,n,m;
int p[15][15][15];
int df[6]={1,-1,0,0,0,0};
int dx[6]={0,0,1,-1,0,0};
int dy[6]={0,0,0,0,1,-1};
char c;
int main()
{
	cin>>f>>n>>m;
	for(int k=1;k<=f;k++)
	{
		for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>c;
			if(c=='#')
			p[k][i][j]=0;
			else
			p[k][i][j]=1;
		}
	}
	int bx,by;
	cin>>bx>>by;
	p[1][bx][by]=2;
	queue<pii>q;
	q.push(pii(1,pi(bx,by)));
	int h,x,y;
	while(!q.empty())
	{
		pii t=q.front();
		q.pop();
		h=t.F,x=t.S.F,y=t.S.S;
		for(int i=0;i<6;i++)
		{
			int a,b,c;
			a=h+df[i];
			b=x+dx[i];
			c=y+dy[i];
			//cout<<p[a][b][c]<<" "<<a<<" "<<b<<" "<<c<<endl;
			if(p[a][b][c]!=1)
			continue;
			p[a][b][c]=2;
			q.push(pii(a,pi(b,c)));
		}
	}
	int ans=0;
	for(int i=1;i<=f;i++)
	for(int j=1;j<=n;j++)
	for(int k=1;k<=m;k++)
	if(p[i][j][k]==2)
	ans++;
	cout<<ans;
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())
#define MAXN                          10
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

char g[10 + MAXN][10 + MAXN][10 + MAXN];
char visited[10 + MAXN][10 + MAXN][10 + MAXN] = {0};

int dr[] = {1,0,0,-1,0,0};
int dc[] = {0,1,0,0,-1,0};
int dh[] = {0,0,1,0,-1,0};
int k, m, n;
int ans = 0;

void floodfill(int r, int c, int h){
    if (r < 0 || r >= k || c < 0 || c >= m || h < 0 || h >= n) return;
    if (g[r][c][h] != '.' || visited[r][c][h] == 1) return;
    //int ans = 1;
    ans++;
    visited[r][c][h] = 1;
    for(int i = 0; i < 6; i++){
        //ans +=
        floodfill(r+dr[i], c + dc[i], h + dh[i]);
    }
   //return ans;
}

int main()
{
    int x,y;
    string trash;
    cin>>k>>n>>m;
    getline(cin, trash);
    forall(i,0,k){
        forall(j,0,n){
            scanf("%s", g[i][j]);
        }
        getline(cin, trash);
    }
    getline(cin, trash);
    cin>>x>>y;
    //cout<<g[y-1][x-1][0]<<endl;
    floodfill(y-1, x-1, 0);
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())
#define MAXN                          10
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

char g[10 + MAXN][10 + MAXN][10 + MAXN];
char visited[10 + MAXN][10 + MAXN][10 + MAXN] = {0};

int dr[] = {1,0,0,-1,0,0};
int dc[] = {0,1,0,0,-1,0};
int dh[] = {0,0,1,0,0,-1};
int k, m, n;
int ans = 0;

void floodfill(int r, int c, int h){
    if (r < 0 || r >= k || c < 0 || c >= n || h < 0 || h >= m) return;
    if (g[r][c][h] != '.' || visited[r][c][h] == 1) return;
    //int ans = 1;
    ans++;
    visited[r][c][h] = 1;
    for(int i = 0; i < 6; i++){
        //ans +=
        floodfill(r+dr[i], c + dc[i], h + dh[i]);
    }
   //return ans;
}

int main()
{
    int x,y;
    string trash;
    cin>>k>>n>>m;
    getline(cin, trash);
    forall(i,0,k){
        forall(j,0,n){
            scanf("%s", g[i][j]);
        }
        getline(cin, trash);
    }
    getline(cin, trash);
    cin>>x>>y;
    //cout<<g[y-1][x-1][0]<<endl;
    floodfill(0,x-1,y-1);
    cout<<ans<<endl;
    /*forall(i,0,k){
        forall(j,0,n){
             forall(l,0,m){
                 printf("%c", g[i][j][l]);
             }
             printf("\n");
        }
        printf("\n");
    }*/
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <conio.h>
#include <cstdio>
using namespace std;

#define all(v) (int)(v.begin(),v.end())
#define lp(i,n) for(int i = 0; i < n; ++i)
#define F first
#define S second
#define     sc(x)	 scanf("%d",&x)
#define scl(x)	 scanf("%I64d",&x)
#define mem(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define MP make_pair
#define SORT(v) sort(all(v))
#define OO (int)1e9
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b)	for(int i=a;i>=b;i--)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;

const int dx[] = { 0, 0, -1, 1 , -1 , 1 , 1, -1};
const int dy[] = { -1, 1, 0, 0 , -1 , -1, 1,  1};
const int INF = 1e10;
const long long M =1e9 + 7;
const int N = 1e5 + 5;

int counter , n , k , m;
string arr[30];
bool vis[50][50];
vector<int>dx1;vector<int>dy1;
bool valid(int i,int j)
{
    return i >= 0 && i < ((n*k) + (k)) && j >=0 && j < m && arr[i][j] =='.';
}
int u , v;
void dfs(int i ,int j)
{
   // cout << i << " " << j << "\n";
    vis[i][j] = 1;
    counter++;
    for(int h = 0; h < 6; ++h)
    {
        u = dx1[h] + i , v = dy1[h] + j;
        if(!vis[u][v] && valid(u,v)&&arr[u][v] == '.')
        {

            dfs(u,v);
        }
    }
}
int main()
{

    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> k >> n >> m;
    int i = 0,temp = n,x , y;
    for(int T = 0; T < k; ++T)
    {
        for(i ; i < temp; ++i)
        cin >> arr[i];
        temp = i + n + 1;
        for(int j = i; j < m; ++j)
        arr[i][j] = ' ';
        i++;

    }
    cin >> x >> y;
    for(int i = 0; i < 4; ++i)
    {
        dx1.push_back(dx[i]);
        dy1.push_back(dy[i]);
    }
    dx1.push_back(n + 1); dx1.push_back(- (n + 1));
    dy1.push_back(0);dy1.push_back(0);
        //    for(int  i = 0; i < 6; ++i)
        //    {
        //        cout << dx1[i] << " " << dy1[i] << "\n";
        //    }
    x--; y--;
    dfs(x,y);
    cout<< counter << "\n";
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <conio.h>
#include <cstdio>
using namespace std;

#define all(v) (int)(v.begin(),v.end())
#define lp(i,n) for(int i = 0; i < n; ++i)
#define F first
#define S second
#define     sc(x)	 scanf("%d",&x)
#define scl(x)	 scanf("%I64d",&x)
#define mem(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define MP make_pair
#define SORT(v) sort(all(v))
#define OO (int)1e9
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b)	for(int i=a;i>=b;i--)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;

const int dx[] = { 0, 0, -1, 1 , -1 , 1 , 1, -1};
const int dy[] = { -1, 1, 0, 0 , -1 , -1, 1,  1};
const int INF = 1e10;
const long long M =1e9 + 7;
const int N = 1e5 + 5;

int counter , n , k , m;
string arr[30];
bool vis[50][50];
vector<int>dx1;vector<int>dy1;
bool valid(int i,int j)
{
    return i >= 0 && i < ((n*k) + (k - 1)) && j >=0 && j < m && arr[i][j] =='.';
}
int u , v;
void dfs(int i ,int j)
{
   // cout << i << " " << j << "\n";
    vis[i][j] = 1;
    counter++;
    for(int h = 0; h < 6; ++h)
    {
        u = dx1[h] + i , v = dy1[h] + j;
        if(!vis[u][v] && valid(u,v)&&arr[u][v] == '.')
        {
            dfs(u,v);
        }
    }
}
int main()
{

    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> k >> n >> m;
    int i = 0,temp = n,x , y;
    for(int T = 0; T < k; ++T)
    {
        for(i ; i < temp; ++i)
        cin >> arr[i];
        temp = i + n + 1;
        for(int j = i; j < m; ++j)
        arr[i][j] = ' ';
        i++;

    }
    cin >> x >> y;
    for(int i = 0; i < 4; ++i)
    {
        dx1.push_back(dx[i]);
        dy1.push_back(dy[i]);
    }
    dx1.push_back(n + 1); dx1.push_back(- (n + 1));
    dy1.push_back(0);dy1.push_back(0);
        //    for(int  i = 0; i < 6; ++i)
        //    {
        //        cout << dx1[i] << " " << dy1[i] << "\n";
        //    }
    x--; y--;
    dfs(x,y);
    cout<< counter << "\n";
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <conio.h>
#include <cstdio>
using namespace std;

#define all(v) (int)(v.begin(),v.end())
#define lp(i,n) for(int i = 0; i < n; ++i)
#define F first
#define S second
#define     sc(x)	 scanf("%d",&x)
#define scl(x)	 scanf("%I64d",&x)
#define mem(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define MP make_pair
#define SORT(v) sort(all(v))
#define OO (int)1e9
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b)	for(int i=a;i>=b;i--)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;

const int dx[] = { 0, 0, -1, 1 , -1 , 1 , 1, -1};
const int dy[] = { -1, 1, 0, 0 , -1 , -1, 1,  1};
const int INF = 1e10;
const long long M =1e9 + 7;
const int N = 1e5 + 5;

int counter , n , k , m;
string arr[30];
bool vis[50][50];
vector<int>dx1;vector<int>dy1;
bool valid(int i,int j)
{
    return i >= 0 && i < ((n*k) + (k + 1)) && j >=0 && j < m && arr[i][j] =='.';
}
int u , v;
void dfs(int i ,int j)
{
   // cout << i << " " << j << "\n";
    vis[i][j] = 1;
    counter++;
    for(int h = 0; h < 6; ++h)
    {
        u = dx1[h] + i , v = dy1[h] + j;
        if(!vis[u][v] && valid(u,v)&&arr[u][v] == '.')
        {

            dfs(u,v);
        }
    }
}
int main()
{

    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> k >> n >> m;
    int i = 0,temp = n,x , y;
    for(int T = 0; T < k; ++T)
    {
        for(i ; i < temp; ++i)
        cin >> arr[i];
        temp = i + n + 1;
        for(int j = i; j < m; ++j)
        arr[i][j] = ' ';
        i++;

    }
    cin >> x >> y;
    for(int i = 0; i < 4; ++i)
    {
        dx1.push_back(dx[i]);
        dy1.push_back(dy[i]);
    }
    dx1.push_back(n + 1); dx1.push_back(- (n + 1));
    dy1.push_back(0);dy1.push_back(0);
        //    for(int  i = 0; i < 6; ++i)
        //    {
        //        cout << dx1[i] << " " << dy1[i] << "\n";
        //    }
    x--; y--;
    dfs(x,y);
    cout<< counter << "\n";
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <conio.h>
#include <cstdio>
using namespace std;

#define all(v) (int)(v.begin(),v.end())
#define lp(i,n) for(int i = 0; i < n; ++i)
#define F first
#define S second
#define     sc(x)	 scanf("%d",&x)
#define scl(x)	 scanf("%I64d",&x)
#define mem(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define MP make_pair
#define SORT(v) sort(all(v))
#define OO (int)1e9
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b)	for(int i=a;i>=b;i--)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;

const int dx[] = { 0, 0, -1, 1 , -1 , 1 , 1, -1};
const int dy[] = { -1, 1, 0, 0 , -1 , -1, 1,  1};
const int INF = 1e10;
const long long M =1e9 + 7;
const int N = 1e5 + 5;

int counter , n , k , m;
string arr[200];
bool vis[200][200];
vector<int>dx1;vector<int>dy1;
bool valid(int i,int j)
{
    return i >= 0 && i < ((n*k) + (k - 1)) && j >=0 && j < m && arr[i][j] =='.';
}
int u , v;
void dfs(int i ,int j)
{
   // cout << i << " " << j << "\n";
    vis[i][j] = 1;
    counter++;
    for(int h = 0; h < 6; ++h)
    {
        u = dx1[h] + i , v = dy1[h] + j;
        if(!vis[u][v] && valid(u,v)&&arr[u][v] == '.')
        {
            dfs(u,v);
        }
    }
}
int main()
{

    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> k >> n >> m;
    int i = 0,temp = n,x , y;
    for(int T = 0; T < k; ++T)
    {
//        for(i ; i < temp; ++i)
//        cin >> arr[i];
        temp = i + n + 1;
        for(int j = i; j < m; ++j)
        arr[i][j] = ' ';
        i++;

    }
    cin >> x >> y;
    for(int i = 0; i < 4; ++i)
    {
        dx1.push_back(dx[i]);
        dy1.push_back(dy[i]);
    }
    dx1.push_back(n + 1); dx1.push_back(- (n + 1));
    dy1.push_back(0);dy1.push_back(0);
        //    for(int  i = 0; i < 6; ++i)
        //    {
        //        cout << dx1[i] << " " << dy1[i] << "\n";
        //    }
    x--; y--;
    dfs(x,y);
    cout<< counter << "\n";
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <conio.h>
#include <cstdio>
using namespace std;

#define all(v) (int)(v.begin(),v.end())
#define lp(i,n) for(int i = 0; i < n; ++i)
#define F first
#define S second
#define     sc(x)	 scanf("%d",&x)
#define scl(x)	 scanf("%I64d",&x)
#define mem(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define MP make_pair
#define SORT(v) sort(all(v))
#define OO (int)1e9
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b)	for(int i=a;i>=b;i--)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;

const int dx[] = { 0, 0, -1, 1 , -1 , 1 , 1, -1};
const int dy[] = { -1, 1, 0, 0 , -1 , -1, 1,  1};
const int INF = 1e10;
const long long M =1e9 + 7;
const int N = 1e5 + 5;

int counter , n , k , m;
string arr[150];
bool vis[200][20];
vector<int>dx1;vector<int>dy1;
bool valid(int i,int j)
{
    return i >= 0 && i < ((n*k) + (k - 1)) && j >=0 && j < m && arr[i][j] =='.';
}
int u , v;
void dfs(int i ,int j)
{
   // cout << i << " " << j << "\n";
    vis[i][j] = 1;
    counter++;
    for(int h = 0; h < 6; ++h)
    {
        u = dx1[h] + i , v = dy1[h] + j;
        if(!vis[u][v] && valid(u,v)&&arr[u][v] == '.')
        {
            dfs(u,v);
        }
    }
}
int main()
{

    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> k >> n >> m;
    int i = 0,temp = n,x , y;
    for(int T = 0; T < k; ++T)
    {
        for(i ; i < temp; ++i)
        cin >> arr[i];
        temp = i + n + 1;
        for(int j = i; j < m; ++j)
        arr[i][j] = ' ';
        i++;

    }
    cin >> x >> y;
    for(int i = 0; i < 4; ++i)
    {
        dx1.push_back(dx[i]);
        dy1.push_back(dy[i]);
    }
    dx1.push_back(n + 1); dx1.push_back(- (n + 1));
    dy1.push_back(0);dy1.push_back(0);
        //    for(int  i = 0; i < 6; ++i)
        //    {
        //        cout << dx1[i] << " " << dy1[i] << "\n";
        //    }
    x--; y--;
    dfs(x,y);
    cout<< counter << "\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define getMat(x, n, m, val) vector<vector<ll>> x(n, vector<ll> (m, val))
#define setp fixed<<setprecision
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll M=1000000000+7;

ll power(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

ll k,n,m;
bool vis[10][10][10]={0};
ll co=0;

void dfs(string s[10][10], ll x,ll y, ll z){
    if(x<0 or y<0 or z<0 or x>=k or y>=n or z>=m)return;
    if(vis[x][y][z])return;
    if(s[x][y][z]=='#')return;
    co++;
    vis[x][y][z]=1;
    dfs(s,x+1,y,z);
    dfs(s,x-1,y,z);
    dfs(s,x,y+1,z);
    dfs(s,x,y-1,z);
    dfs(s,x,y,z+1);
    dfs(s,x,y,z-1);
}

int main(){
    fastio;

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    // if( __cplusplus == 201103L ) std::cout << "C++11\n" ;
    // else if( __cplusplus == 19971L ) std::cout << "C++98\n" ;
    // else std::cout << "pre-standard C++\n" ;

    ll t=1;
    // cin>>t;
    while(t--){
        cin>>k>>n>>m;
        string s[10][10];
        for(ll i=0;i<k;i++){
            for(ll j=0;j<n;j++){
                cin>>s[i][j];
            }
        }
        ll x,y,z;
        cin>>y>>z;
        dfs(s,0,y-1,z-1);
        cout<<co<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define getMat(x, n, m, val) vector<vector<ll>> x(n, vector<ll> (m, val))
#define setp fixed<<setprecision
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll M=1000000000+7;

ll power(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

ll k,n,m;
bool vis[10][10][10]={0};
ll co=0;

void dfs(string s[10][10], ll x,ll y, ll z){
    if(x<0 or y<0 or z<0 or x>=k or y>=n or z>=m)return;
    if(vis[x][y][z])return;
    if(s[x][y][z]=='#')return;
    co++;
    vis[x][y][z]=1;
    dfs(s,x+1,y,z);
    dfs(s,x-1,y,z);
    dfs(s,x,y+1,z);
    dfs(s,x,y-1,z);
    dfs(s,x,y,z+1);
    dfs(s,x,y,z-1);
}

int main(){
    fastio;

    // #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    // #endif

    // if( __cplusplus == 201103L ) std::cout << "C++11\n" ;
    // else if( __cplusplus == 19971L ) std::cout << "C++98\n" ;
    // else std::cout << "pre-standard C++\n" ;

    ll t=1;
    // cin>>t;
    while(t--){
        cin>>k>>n>>m;
        string s[10][10];
        for(ll i=0;i<k;i++){
            for(ll j=0;j<n;j++){
                cin>>s[i][j];
            }
        }
        ll x,y,z;
        cin>>y>>z;
        dfs(s,0,y-1,z-1);
        cout<<co<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
bool cube[11][11][11];
int answer=0;
int xder[] = { 0,0,1,-1,0,0 };
int yder[] = { -1,1,0,0,0,0 };
int zder[] = {0,0,0,0,-1,1};

void dfs(int z,int y,int x)
{
    answer++;
    cube[z][y][x]=false;

    for(int i=0;i<6;i++)
    {
        if(cube[z+zder[i]][y+yder[i]][x+xder[i]])
            dfs(z+zder[i],y+yder[i],x+xder[i]);
    }
}

int main() {
int k,m,n;
cin>>k>>m>>n;
for(int i=1;i<=k;i++)
    for(int j=1;j<=m;j++)
        for(int l=1;l<=n;l++)
        {
            char x;
            cin>>x;
            if(x=='.')
            cube[i][j][l]=true;

        }
int x,y;
cin>>y>>x;
dfs(1,y,x);

cout<<answer;
return 0;
}


#include <iostream>
#include <vector>
using namespace std;
bool cube[12][12][12]; //always leave some space

int answer=0;
int xder[] = {0,0,1,-1,0,0};
int yder[] = {-1,1,0,0,0,0};
int zder[] = {0,0,0,0,-1,1};
int count=0;    //just for debugging
void dfs(int z,int y,int x)
{
    answer++;
    cube[z][y][x]=false;

    for(int i=0;i<6;i++)
    {
        if(cube[z+zder[i]][y+yder[i]][x+xder[i]])
            {
                dfs(z+zder[i],y+yder[i],x+xder[i]);
            }
    }

}
//if you see the output it is 555 and it sholud be 540
//if you see this statment tell me
int main() {
int k,m,n;
cin>>k>>m>>n;

for(int i=0;i<=11;i++)
    for(int j=0;j<=11;j++)
        for(int l=0;l<=11;l++)
                cube[i][j][l]=false;

for(int i=1;i<=k;i++)
    for(int j=1;j<=m;j++)
        for(int l=1;l<=n;l++)
        {
            char x;
            cin>>x;
            if(x=='.')
                {cube[i][j][l]=true;}

        }

int x,y;
cin>>y>>x;

dfs(1,y,x);

cout<<answer;

}


#include <iostream>
#include <vector>
using namespace std;
bool cube[12][12][12]; //always leave some space

int answer=0;
int xder[] = {0,0,1,-1,0,0};
int yder[] = {-1,1,0,0,0,0};
int zder[] = {0,0,0,0,-1,1};
int count=0;    //just for debugging
void dfs(int z,int y,int x)
{
    answer++;
    cube[z][y][x]=false;

    for(int i=0;i<6;i++)
    {
        if(cube[z+zder[i]][y+yder[i]][x+xder[i]])
            {
                dfs(z+zder[i],y+yder[i],x+xder[i]);
            }
    }

}
//if you see the output it is 555 and it sholud be 540
//if you see this statment tell me
int main() {
int k,m,n;
cin>>k>>m>>n;

for(int i=0;i<=10;i++)
    for(int j=0;j<=10;j++)
        for(int l=0;l<=10;l++)
                cube[i][j][l]=false;

for(int i=1;i<=k;i++)
    for(int j=1;j<=m;j++)
        for(int l=1;l<=n;l++)
        {
            char x;
            cin>>x;
            if(x=='.')
                {cube[i][j][l]=true;}

        }

int x,y;
cin>>y>>x;

dfs(1,y,x);

cout<<answer;

}


#include <iostream>

using namespace std;

int counter = 0, k, n, m;

char*** arr;
bool*** visited;

void dfs (int r, int x, int y){
    counter++;
    visited[r][x][y] = true;
    if (r - 1 >= 0 && arr[r - 1][x][y] == '.' && !visited[r - 1][x][y])
        dfs(r - 1, x, y);

    if (r + 1 < k && arr[r + 1][x][y] == '.' && !visited[r + 1][x][y])
        dfs(r + 1, x, y);

    if (x - 1 >= 0 && arr[r][x - 1][y] == '.' && !visited[r][x - 1][y])
        dfs(r, x - 1, y);

    if (x + 1 < n && arr[r][x + 1][y] == '.' && !visited[r][x + 1][y])
        dfs(r, x + 1, y);

    if (y - 1 >= 0 && arr[r][x][y - 1] == '.' && !visited[r][x][y - 1])
        dfs(r, x , y - 1);

    if (y + 1 < m && arr[r][x][y + 1] == '.' && !visited[r][x][y + 1])
        dfs(r, x , y + 1);
}

int main()
{
    int x, y;
    cin >> k >> n >> m;
    arr = new char**[k];
    for(int i = 0; i < k; i++){
        arr[i] = new char*[n];
        for(int j = 0; j < n; j++){
            arr[i][j]= new char[m];
        }
    }

    visited = new bool**[k];
    for(int i = 0; i < k; i++){
        visited[i] = new bool*[n];
        for(int j = 0; j < n; j++){
            visited[i][j]= new bool[m];
        }
    }

    for (int r = 0; r < k; r++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                cin >> arr[r][i][j];
                visited[r][i][j] = false;
            }
        }
    }

    cin >> x >> y;
    dfs (0, x - 1, y - 1);
    cout << counter;

    return 0;
}


#include <iostream>

using namespace std;

int counter = 0, k, n, m;

char*** arr;
bool*** visited;

void dfs (int r, int x, int y){
    counter++;
    visited[r][x][y] = true;
    if (r - 1 >= 0 && arr[r - 1][x][y] == '.' && !visited[r - 1][x][y])
        dfs(r - 1, x, y);

    if (r + 1 < k && arr[r + 1][x][y] == '.' && !visited[r + 1][x][y])
        dfs(r + 1, x, y);

    if (x - 1 >= 0 && arr[r][x - 1][y] == '.' && !visited[r][x - 1][y])
        dfs(r, x - 1, y);

    if (x + 1 < n && arr[r][x + 1][y] == '.' && !visited[r][x + 1][y])
        dfs(r, x + 1, y);

    if (y - 1 >= 0 && arr[r][x][y - 1] == '.' && !visited[r][x][y - 1])
        dfs(r, x , y - 1);

    if (y + 1 < m && arr[r][x][y + 1] == '.' && !visited[r][x][y + 1])
        dfs(r, x , y + 1);
}

int main()
{
    int x, y;
    cin >> k >> n >> m;
    arr = new char**[k];
    for(int i = 0; i < k; i++){
        arr[i] = new char*[n];
        for(int j = 0; j < n; j++){
            arr[i][j]= new char[m];
        }
    }

    visited = new bool**[k];
    for(int i = 0; i < k; i++){
        visited[i] = new bool*[n];
        for(int j = 0; j < n; j++){
            visited[i][j]= new bool[m];
        }
    }

    for (int r = 0; r < k; r++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                cin >> arr[r][i][j];
            }
        }
    }

    cin >> x >> y;
    dfs (0, x - 1, y - 1);
    cout << counter;

    return 0;
}


#include <iostream>
#include <tuple>
#include <queue>

using namespace std;

int k, n, m, y, x, result;
char map[10][10][10];
int dx[] = {1, -1, 0, 0, 0, 0}, dy[] = {0, 0, -1, 1, 0, 0}, dz[] = {0, 0, 0, 0, -1, 1};

int main(void){
    cin >> k >> n >> m;
    for(int i = 0; i < k; i++)
        for(int j = 0; j < n; j++)
            for(int l = 0; l < n; l++)
                cin >> map[i][j][l];
    cin >> y >> x;
    y--;x--;
    queue<tuple<int, int, int>> que;
    que.push(make_tuple(0, y, x));
    map[0][y][x] = '#';
    while(!que.empty()){
        tuple<int, int, int> temp = que.front();
        que.pop();
        result++;
        for(int i = 0; i < 6; i++){
            int next_k = get<0>(temp) + dz[i], next_y = get<1>(temp) + dy[i], next_x = get<2>(temp) + dx[i];
            if (next_k >= 0 && next_k < k && next_y >= 0 && next_y < n && next_x >= 0 && next_x < m && map[next_k][next_y][next_x] == '.'){
                que.push(make_tuple(next_k, next_y, next_x));
                map[next_k][next_y][next_x] = '#';
            }
        }
    }
    cout << result << endl;
}


#include <iostream>
#include <tuple>
#include <queue>

using namespace std;

int k, n, m, y, x, result;
char map[10][10][10];
int dx[] = {1, -1, 0, 0, 0, 0}, dy[] = {0, 0, -1, 1, 0, 0}, dz[] = {0, 0, 0, 0, -1, 1};

int main(void){
    cin >> k >> n >> m;
    for(int i = 0; i < k; i++)
        for(int j = 0; j < n; j++)
            for(int l = 0; l < m; l++)
                cin >> map[i][j][l];
    cin >> y >> x;
    y--;x--;
    queue<tuple<int, int, int>> que;
    que.push(make_tuple(0, y, x));
    map[0][y][x] = '#';
    while(!que.empty()){
        tuple<int, int, int> temp = que.front();
        que.pop();
        result++;
        for(int i = 0; i < 6; i++){
            int next_k = get<0>(temp) + dz[i], next_y = get<1>(temp) + dy[i], next_x = get<2>(temp) + dx[i];
            if (next_k >= 0 && next_k < k && next_y >= 0 && next_y < n && next_x >= 0 && next_x < m && map[next_k][next_y][next_x] == '.'){
                que.push(make_tuple(next_k, next_y, next_x));
                map[next_k][next_y][next_x] = '#';
            }
        }
    }
    cout << result << endl;
}


#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#define ll long long
using namespace std;
char A[10][10][10];
ll cont = 0;
ll n, m , k;
void dfs(ll x, ll y, ll z){
    cont++;
    A[x][y][z] = '#';
    if( x-1 > 0 && A[x-1][y][z] == '.'){
        dfs(x-1,y,z);
    }
    if( y-1 > 0 && A[x][y - 1][z] == '.'){
        dfs(x,y - 1,z);
    }
    if( z-1 > 0 && A[x][y][z-1] == '.'){
        dfs(x,y,z-1);
    }

    if( x+1 < n && A[x+1][y][z] == '.'){
        dfs(x+1,y,z);
    }
    if( y+1 < m && A[x][y + 1][z] == '.'){
        dfs(x,y + 1,z);
    }
    if( z+1 < k && A[x][y][z+1] == '.'){
        dfs(x,y,z+1);
    }
}
int main()
{
    //std::ifstream in("test.txt");
    //std::cin.rdbuf(in.rdbuf());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>k>>n>>m;

    for(ll i = 0; i < k;i ++){
        for(ll j = 0; j < n; j++){
            string a;
            cin>>a;
            for(ll h = 0; h < a.length(); h++){
                A[i][j][h] = a[h];
            }
        }
    }
    ll x,y;
    cin>>x>>y;
    x--;
    y--;
    dfs(x,y,0);
    cout<<cont;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#define ll long long
using namespace std;
char A[10][10][10];
ll cont = 1;
ll n, m , k;
void dfs(ll x, ll y, ll z){
    A[z][x][y] = '#';
    if( x-1 >= 0 && A[z][x-1][y] == '.'){
        cont++;
        dfs(x-1,y,z);
    }
    if( y-1 >= 0 && A[z][x][y - 1] == '.'){
        cont++;
        dfs(x,y - 1,z);
    }
    if( z-1 >= 0 && A[z-1][x][y] == '.'){
        cont++;
        dfs(x,y,z-1);
    }

    if( x+1 < n && A[z][x+1][y] == '.'){
        cont++;
        dfs(x+1,y,z);
    }
    if( y+1 < m && A[z][x][y + 1] == '.'){
        cont++;
        dfs(x,y + 1,z);
    }
    if( z+1 < k && A[z+1][x][y] == '.'){
        cont++;
        dfs(x,y,z+1);
    }
}
int main()
{
    //std::ifstream in("test.txt");
    //std::cin.rdbuf(in.rdbuf());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>k>>n>>m;

    for(ll i = 0; i < k;i ++){
        for(ll j = 0; j < n; j++){
            string a;
            cin>>a;
            for(ll h = 0; h < m; h++){
                A[i][j][h] = a[h];
            }
        }
    }

    ll x,y;
    cin>>x>>y;
    x--;
    y--;
    dfs(x,y,0);
    cout<<cont;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll l,n,m,i,j,k,cnt;
char a[15][15][15];
bool b[15][15][15];
void dfs( int i,int j,int k )
{
    if( a[i][j][k] == '#' )return ;
    b[i][j][k]=1;
    cnt++;
    for(int I=-1;I<2;I++)
        for(int J=-1;J<2;J++)
            for(int K=-1;K<2;K++)
            if( ( I || J || K ) && ! b[i+I][j+J][k+K]  )
            dfs( i+I,j+J,k+K );

}
int main()
{
    memset( b,1,sizeof(b) );
    cin >> l >> n >> m ;
    for(i=1;i<=l;i++)
        for(j=1;j<=n;j++)
        for(k=1;k<=m;b[i][j][k]=0,k++)
        cin >> a[i][j][k];
    cin >> i >> j;
    dfs(1,i,j);
    cout << cnt;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll l,n,m,i,j,k,cnt;
char a[15][15][15];
bool b[15][15][15];
void dfs( int i,int j,int k )
{
    if( a[i][j][k] == '#' )return ;
    b[i][j][k]=1;
    cnt++;
    for(int I=-1;I<2;I++)
        for(int J=-1;J<2;J++)
            for(int K=-1;K<2;K++)
            if( ( I || J || K ) && abs(I) + abs(J) + abs(K) == 1 && ! b[i+I][j+J][k+K]  )
            dfs( i+I,j+J,k+K );

}
int main()
{
    memset( b,1,sizeof(b) );
    cin >> l >> n >> m ;
    for(i=1;i<=l;i++)
        for(j=1;j<=n;j++)
        for(k=1;k<=m;b[i][j][k]=0,k++)
        cin >> a[i][j][k];
    cin >> i >> j;
    dfs(1,i,j);
    cout << cnt;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <memory.h>
#include <bitset>
using namespace std;

int n, m, k;
char a[12][12][12];
bool was[12][12][12];
int ret = 0;

void dfs(int z, int i, int j)
{
	if (was[z][i][j])
		return;
	was[z][i][j] = true;
	if (a[z][i][j] == '#')
		return;
	++ret;
	for (int d = -1; d <= 1; d += 2)
	{
		if (z + d >= 0 && z + d < k)
			dfs(z + d, i, j);
	}
	for (int d = -1; d <= 1; d += 2)
	{
		if (i + d >= 0 && i + d < n)
			dfs(z, i + d, j);
	}
	for (int d = -1; d <= 1; d += 2)
	{
		if (j + d >= 0 && j + d < m)
			dfs(z, i, j + d);
	}
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> k >> n >> m;

	for (int i = 0; i < k; ++i)
	{
		for (int j = 0; j < n; ++j)
			scanf("%s", a[i][j]);
	}
	int x, y;
	scanf("%d %d", &x, &y);
	--x;
	--y;
	dfs(0, x, y);
	printf("%d", ret);
	return 0;
}


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

#define mp make_pair
#define ll long long int
#define f(i,n) for(ll i=0;i<n;i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define  pb push_back
#define a(s) a.size();
#define v() vector<ll>v
struct  node
{ll h,r,c;

}p1;
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
            ll n,k,m;cin>>k>>n>>m;
    char a[k+1][n+1][m+1];
    ff(i,k)
    {ff(j,n)
        {
            ff(p,m)
            {
                cin>>a[i][j][p];
            }
        }

    }
    ll x1,y1;cin>>x1>>y1;
    queue<node>q;
    q.push({1,x1,y1});a[1][x1][y1]='#';
ll ans=1;
    while(!q.empty()) {
        ll rr = (q.front()).h;
        ll cc = (q.front()).r;
        ll hh = (q.front()).c;
        ///cout<<rr<<" "<<cc<<" "<<hh<<" ";
        // cout<<q.front()<<" ";
        q.pop();
        ll a1[6] = {0, 0, 1, -1, 0, 0};
        ll a2[6] = {1, -1, 0, 0, 0, 0};
        ll a3[6] = {0, 0, 0, 0, 1, -1};
        f(y, 6) {

                if (a[rr + a3[y]][cc + a1[y]][hh + a2[y]] == '.') {
                  //  cout<<rr+a3[y]<<" ";
                    q.push({rr + a3[y], cc + a1[y], hh + a2[y]});
                    ans++;
                    a[rr + a3[y]][cc + a1[y]][hh + a2[y]] = '#';
                }

        }
    }
cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char layer[11][11][11] = {0};
int n,m,k,ans=0;
void dfs(int a,int b,int c)
{
	if(layer[a][b][c]=='#' || a<0 || a>=k || b<0 || b>=n || c<0 || c>=m)
	return;
	layer[a][b][c]='#';
	ans++;
	dfs(a+1,b,c);
	dfs(a-1,b,c);
	dfs(a,b+1,c);
	dfs(a,b-1,c);
	dfs(a,b,c+1);
	dfs(a,b,c-1);
}
int main()
{
	cin>>k>>n>>m;
	for(int i=0;i<k;i++)
	for(int j=0;j<n;j++)
	for(int q=0;q<m;j++)
	cin>>layer[i][j][q];
	int x,y;
	cin>>x>>y;
	x--,y--;
	dfs(0,x,y);
	cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
char layer[11][11][11] = {0};
int n,m,k,ans=0;
void dfs(int a,int b,int c)
{
	if(layer[a][b][c]=='#' || a<0 || a>=k || b<0 || b>=n || c<0 || c>=m)
	return;
	layer[a][b][c]='#';
	ans++;
	dfs(a+1,b,c);
	dfs(a-1,b,c);
	dfs(a,b+1,c);
	dfs(a,b-1,c);
	dfs(a,b,c+1);
	dfs(a,b,c-1);
}
int main()
{
	cin>>k>>n>>m;
	for(int i=0;i<k;i++)
	for(int j=0;j<n;j++)
	cin>>layer[i][j];
	int x,y;
	cin>>x>>y;
	x--,y--;
	dfs(0,x,y);
	cout<<ans<<"\n";
}


#include <iostream>
#include <string>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <map>
#include<unordered_map>
#include <set>
#include <cstring>
#include <iomanip>
#include <list>
#include <bitset>
//#include<bits/stdc++.h>
#define itn int
#define mp make_pair
#define endl "\n"
#define M_PI 3.14159265358979323846
using namespace std;
typedef long long ll;
int mod = 1e9 + 7 ;
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b); }
ll n,m,k;
char mat[20][20][20];
int reach[20][20][20];
ll cnt;
int pp[]={0,0,1,-1};
int qq[]={1,-1,0,0};
void dfs(ll layer,ll hori,ll ver)
{
    cnt++;
   // cout<<layer<<" "<<hori<<" "<<ver<<endl;
    reach[layer][hori][ver]=1;
    for(int i=0;i<4;i++)
    {
        if(hori+pp[i]>0 && hori+pp[i]<=n && ver+qq[i]>0 && ver+qq[i]<=m && reach[layer][hori+pp[i]][ver+qq[i]]==0&& mat[layer][hori+pp[i]][ver+qq[i]]=='.')
        {
            reach[layer][hori+pp[i]][ver+qq[i]]=1;
            dfs(layer,hori+pp[i],ver+qq[i]);
        }
    }
    if(layer>1 && mat[layer-1][hori][ver]=='.' && reach[layer-1][hori][ver]==0)
    {
        reach[layer-1][hori][ver]=1;
        dfs(layer-1,hori,ver);
    }
    if(layer<k && mat[layer+1][hori][ver]=='.' && reach[layer+1][hori][ver]==0)
    {
        reach[layer+1][hori][ver]=1;
        dfs(layer+1,hori,ver);
    }

}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll i,j,x,y;
    cin>>k>>n>>m;
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(x=1;x<=m;x++)
            {
                cin>>mat[i][j][x];
            }
        }
    }
    cin>>x>>y;
    dfs(1,x,y);
    cout<<cnt;
}


#include <iostream>
#include <string>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <map>
#include<unordered_map>
#include <set>
#include <cstring>
#include <iomanip>
#include <list>
#include <bitset>
//#include<bits/stdc++.h>
#define itn int
#define mp make_pair
#define endl "\n"
#define M_PI 3.14159265358979323846
using namespace std;
typedef long long ll;
int mod = 1e9 + 7 ;
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b); }
ll n,m,k;
char mat[20][20][20];
int reach[20][20][20];
ll cnt;
int pp[]={0,0,1,-1};
int qq[]={1,-1,0,0};
void dfs(ll layer,ll hori,ll ver)
{
    cnt++;
    //cout<<layer<<" "<<hori<<" "<<ver<<endl;
    reach[layer][hori][ver]=1;
    for(int i=0;i<4;i++)
    {
        if(hori+pp[i]>0 && hori+pp[i]<=m && ver+qq[i]>0 && ver+qq[i]<=n && reach[layer][hori+pp[i]][ver+qq[i]]==0&& mat[layer][hori+pp[i]][ver+qq[i]]=='.')
        {
            reach[layer][hori+pp[i]][ver+qq[i]]=1;
            dfs(layer,hori+pp[i],ver+qq[i]);
        }
    }
    if(layer>1 && mat[layer-1][hori][ver]=='.' && reach[layer-1][hori][ver]==0)
    {
        reach[layer-1][hori][ver]=1;
        dfs(layer-1,hori,ver);
    }
    if(layer<k && mat[layer+1][hori][ver]=='.' && reach[layer+1][hori][ver]==0)
    {
        reach[layer+1][hori][ver]=1;
        dfs(layer+1,hori,ver);
    }

}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll i,j,x,y;
    cin>>k>>n>>m;
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(x=1;x<=m;x++)
            {
                cin>>mat[i][j][x];
            }
        }
    }
    cin>>x>>y;
    dfs(1,x,y);
    cout<<cnt;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

int used[11][11][11];
char c[11][11][11];
int dk[] = {0, 0, 1, -1, 0, 0};
int dx[] = {1, -1, 0, 0, 0, 0};
int dy[] = {0, 0, 0, 0, 1, -1};
int k, n, m;
bool check(int i, int j, int x){
	return i >= 0 && j >= 0 && x >= 0 && i < k && j < n && x < m;
}
int result = 0;
void dfs(int i, int j, int x){
	used[i][j][x] = 1;
	++result;
	for(int y = 0; y < 6; ++y){
		int ci = i + dk[y];
		int cj = j + dx[y];
		int cx = x + dy[y];
		if(check(ci, cj, cx) == true &&
		!used[ci][cj][cx] &&
		c[ci][cj][cx] == '.'){
			dfs(ci, cj, cx);
		}
	}
}
void solve()
{
	cin >> k >> n >> m;
	for(int i = 0; i < k; ++i){
		for(int j = 0; j < n; ++j){
			for(int x = 0; x < m; ++x){
				cin >> c[i][j][x];
			}
		}
	}
	int op, cl;
	cin >> op >> cl;
	for(int i = 0; i < k; ++i){
		for(int j = 0; j < n; ++j){
			for(int x = 0; x < m; ++x){
				if(c[i][j][x] != '.') continue;
				if(!used[i][j][x] && j == op - 1 && x == cl - 1){
					dfs(i, j, x);
				}
			}
		}
		break;
	}
	cout << result << endl;
}

int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

int used[11][11][11];
char c[11][11][11];
int dk[] = {0, 0, 1, -1, 0, 0};
int dx[] = {1, -1, 0, 0, 0, 0};
int dy[] = {0, 0, 0, 0, 1, -1};
int k, n, m;
bool check(int i, int j, int x){
	return i >= 0 && j >= 0 && x >= 0 && i < k && j < n && x < m;
}
int result = 0;
void dfs(int i, int j, int x){
	used[i][j][x] = 1;
	++result;
	for(int y = 0; y < 6; ++y){
		int ci = i + dk[y];
		int cj = j + dx[y];
		int cx = x + dy[y];
		if(check(ci, cj, cx) == true &&
		!used[ci][cj][cx] &&
		c[ci][cj][cx] == '.'){
			dfs(ci, cj, cx);
		}
	}
}
void solve()
{
	cin >> k >> n >> m;
	for(int i = 0; i < k; ++i){
		for(int j = 0; j < n; ++j){
			for(int x = 0; x < m; ++x){
				cin >> c[i][j][x];
			}
		}
	}
	int op, cl;
	cin >> op >> cl;
	for(int i = 0; i < k; ++i){
		for(int j = 0; j < n; ++j){
			for(int x = 0; x < m; ++x){
				if(c[i][j][x] != '.') continue;
				if(!used[i][j][x] && j == op - 1 && x == cl - 1){
					dfs(i, j, x);
				}
			}
		}
	}
	cout << result << endl;
}

int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

typedef long long int ll;
typedef unsigned long long int ull;

#define dbg printf("in\n")
#define nl printf("\n");
#define N 15
#define inf 100000000

#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)

#define pf(n) printf("%d ",n)
#define pff(n,m) printf("%d %d\n",n,m)
#define pffl(n,m) printf("%I64d %I64d\n",n,m)
#define pfl(n) printf("%I64d ",n)
#define pfs(s) printf("%s",s)

#define pb push_back
#define pp pair<int,int>

using namespace std;

int n, m, z;
bool vis[N][N][N];
char adj[N][N][N];

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

void dfs(int l, int x, int y)
{
	//cout << l << " " << x << " " << y;nl
	if (adj[l][x][y] == '#') return;

	vis[l][x][y] = 1;
	for (int i = 0; i < 6; i++)
	{
		int c = l + dz[i];
		int a = x + dx[i];
		int b = y + dy[i];

		//cout << c << " " << a << " " << b << " " << vis[c][a][b];nl
		if (a > 0 && b > 0 && c > 0 && c <= z && a <= n && b <= m && !vis[c][a][b])
			dfs(c, a, b);
	}
}

int main()
{
	freopen("in2.txt", "r", stdin);

	int i, j, k;
	int x, y;
	char ch;

	cin >> z >> n >> m;
	for (i = 1; i <= z; i++)
	{
		for (j = 1; j <= n; j++)
		{
			for (k = 1; k <= m; k++)
				cin >> ch, adj[i][j][k] = ch;
		}
	}

	cin >> x >> y;
	memset(vis, 0, sizeof(vis));

	dfs(1, x, y);

	int ans = 0;
	for (i = 1; i <= z; i++)
	{
		for (j = 1; j <= n; j++)
		{
			for (k = 1; k <= m; k++)
			{
				if (vis[i][j][k]) ans++;
			}
		}
	}

	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
char board[11][11][11];
int dz[] = {1,-1,0,0,0,0};
int dr[] = {0,0,1,-1,0,0};
int dc[] = {0,0,0,0,1,-1};
int ans = 0,k,n,m;
bool visited[11][11][11] = {0};
bool isvalid(int x,int y,int z){

    if(x<=0 || y<=0 || z<=0 || x>k || y>n || z>m || board[x][y][z]=='#')
       return false;
    return true;
}
void dfs(int x,int y,int z){

    visited[x][y][z] = 1;
    ans++;
    for(int u=0;u<6;u++){

        int xx = x + dz[u];
        int yy = y + dr[u];
        int zz = z + dc[u];
        if(isvalid(xx,yy,zz) && visited[xx][yy][zz] == false){

            dfs(xx,yy,zz);
        }
    }
}
int main() {

    cin >> k >> n >> m;
    string temp;
    for(int i=1;i<=k;i++){

        for(int j=1;j<=n;j++){

            for(int a=1;a<=m;a++){

                cin >> board[i][j][a];
              ///  cout << board[i][j][a]<<' ';
            }
          ///  cout << endl;
        }
     ///   cout << endl;
    }
     int c1,c2;
     cin >> c1 >> c2;
     dfs(1,c1,c2);
     cout << ans ;
}


#include <bits/stdc++.h>
using namespace std;
char board[11][11][11];
int dz[] = {1,-1,0,0,0,0};
int dr[] = {0,0,1,-1,0,0};
int dc[] = {0,0,0,0,1,-1};
int ans = 0,k,n,m;
bool visited[11][11][11] = {0};
bool isvalid(int x,int y,int z){

    if(x<=0 || y<=0 || z<=0 || x>k || y>n || z>m || board[x][y][z]=='#')
       return false;
    return true;
}
void dfs(int x,int y,int z){

    visited[x][y][z] = 1;
    ans++;
    for(int u=0;u<6;u++){

        int xx = x + dz[u];
        int yy = y + dr[u];
        int zz = z + dc[u];
        if(isvalid(xx,yy,zz) && visited[xx][yy][zz] == false){

            dfs(xx,yy,zz);
        }
    }
}
int main() {

    cin >> k >> n >> m;
    string temp;
    for(int i=1;i<=k;i++){

        for(int j=1;j<=m;j++){

            for(int a=1;a<=n;a++){

                cin >> board[i][j][a];
            }
        }

    }
     int c1,c2;
     cin >> c1 >> c2;
     dfs(1,c1,c2);
     cout << ans ;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 1e9 + 7;
const int N = 11;
char a[N][N][N];
bool vis[N][N][N];
int n, m, k, ans = 0;
int dx[] = {0, 0, 0, -1, 0, 1};
int dy[] = {0, 0, -1, 0, 1, 0};
int dz[] = {1, -1, 0, 0, 0, 0};

void dfs(int x, int y, int z){
	ans++;
	vis[x][y][z] = true;
	for(int i = 0; i < 6; i++){
		int du = x + dx[i];
		int dv = y + dy[i];
		int dk = z + dz[i];
		if (du < 1 || du > n || dv < 1 || dv > m || dk < 1 || dk > k) continue;
		if(!vis[du][dv][dk] && a[du][dv][dk] == '.')
			dfs(du, dv, dk);
	}
}
int main(){
	ios :: sync_with_stdio(false); cin.tie(0);
	cin >> k >> n >> m;
	for(int t = 1; t <= k; t++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				cin >> a[i][j][t];
			}
		}
	}
	int u, v;
	cin >> u >> v;
	dfs(u, v, 1);
	cout << ans << endl;
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>

#define memc(a, x) memset(a,x,sizeof(a))
#define ll long long
#define irp(i, a, b) for(int i=a;i<b;i++)
#define drp(i, a, b) for(int i=a;i>b;i--)

using namespace std;

int main() {
//    freopen("input.txt", "r", stdin);
    int a = 0, b = 0, t = 0;
    int init;
    cout << '?' << ' ' << 0 << ' ' << 0 << endl;
    cin >> init;
    drp(i, 29, -1) {
        int x;
        cout << '?' << ' ' << (a | (1 << i)) << ' ' << (b | (1 << i)) << endl;
        cin >> x;
        if (x == init) {
            cout << '?' << ' ' << (a | (1 << i)) << ' ' << b << endl;
            cin >> x;
            if (init == 0) {
                if (x == -1) {
                    a |= 1 << i;
                    b |= 1 << i;
                }
            }
            else if (x == -1) {
                a |= 1 << i;
                b |= 1 << i;
            }
        }
        else if (i > 0 || x != 0) {
            if (init == 1) {
                a |= 1 << i;
            }
            else {
                b |= 1 << i;
            }
        }
        else {
            a |= 1 << i;
            b |= 1 << i;
        }
    }
    cout << '!' << ' ' << a << ' ' << b << endl;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>

#define memc(a, x) memset(a,x,sizeof(a))
#define ll long long
#define irp(i, a, b) for(int i=a;i<b;i++)
#define drp(i, a, b) for(int i=a;i>b;i--)

using namespace std;

int main() {
//    freopen("input.txt", "r", stdin);
    int a = 0, b = 0;
    int init;
    cout << '?' << ' ' << 0 << ' ' << 0 << endl;
    cin >> init;

    drp(i, 29, -1) {

        int x1, x2;
        cout << '?' << ' ' << (a | (1 << i)) << ' ' << b << endl;
        cin >> x1;
        cout << '?' << ' ' << a << ' ' << (b | (1 << i)) << endl;
        cin >> x2;
        if(x1==x2){
            if(init==1){
                a|=1<<i;
            }
            else if(init==-1){
                b|=1<<i;
            }
            init=x1;
        }
        else{
            if(init==0){
                if(x1<x2){
                    a|=1<<i;
                    b|=1<<i;
                }
            }
            else if(init ==x2){
                    a|=1<<i;
                    b|=1<<i;
            }
        }
    }
    cout << '!' << ' ' << a << ' ' << b << endl;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>

#define memc(a, x) memset(a,x,sizeof(a))
#define ll long long
#define irp(i, a, b) for(int i=a;i<b;i++)
#define drp(i, a, b) for(int i=a;i>b;i--)

using namespace std;
int xa = 18, xb = 511;

int ck(int c, int d) {
    if ((xa ^ c) == (xb ^ d)) {
        return 0;
    } else if ((xa ^ c) > (xb ^ d)) {
        return 1;
    } else {
        return -1;
    }
}

int main() {
//    freopen("input.txt", "r", stdin);
    int a = 0, b = 0;
    int init;
    cout << '?' << ' ' << 0 << ' ' << 0 << endl;
//    fflush(stdout);
    cin >> init;
//    init = ck(0, 0);
//    cout << '#' << init << endl;
    drp(i, 29, -1) {
        int x1, x2;
        cout << '?' << ' ' << (a | (1 << i)) << ' ' << b << endl;
//        fflush(stdout);
        cin >> x1;
//        x1 = ck((a | (1 << i)), b);
        cout << '?' << ' ' << a << ' ' << (b | (1 << i)) << endl;
//        fflush(stdout);
        cin >> x2;
//        x2 = ck(a, (b | (1 << i)));
//        printf("$%d %d %d\n", init, x1, x2);
        if (x1 == x2) {
            if (init == 1) {
                a ^= 1 << i;
            } else if (init == -1) {
                b ^= 1 << i;
            }
            init = x1;
        } else if (x1 == -1) {
            a ^= 1 << i;
            b ^= 1 << i;
        }
//        cout << '!' << ' ' << a << ' ' << b << endl;
    }
    cout << '!' << ' ' << a << ' ' << b << endl;
//    fflush(stdout);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>

#define memc(a, x) memset(a,x,sizeof(a))
#define ll long long
#define irp(i, a, b) for(int i=a;i<b;i++)
#define drp(i, a, b) for(int i=a;i>b;i--)

using namespace std;

int main() {
//    freopen("input.txt", "r", stdin);
    int a = 0, b = 0, t = 0;
    int init;
    cout << '?' << ' ' << 0 << ' ' << 0 << endl;
    cin >> init;
    drp(i, 29, -1) {
        int x;
        cout << '?' << ' ' << (a | (1 << i)) << ' ' << (b | (1 << i)) << endl;
        cin >> x;
        if (x == init) {
            cout << '?' << ' ' << (a | (1 << i)) << ' ' << b << endl;
            cin >> x;
            if (init == 0) {
                if (x == -1) {
                    a |= 1 << i;
                    b |= 1 << i;
                }
            }
            else if (init * x == -1) {
                a |= 1 << i;
                b |= 1 << i;
            }
        }
        else if (i > 0 || x != 0) {
            if (init == 1) {
                a |= 1 << i;
            }
            else {
                b |= 1 << i;
            }
        }
        else {
            a |= 1 << i;
            b |= 1 << i;
        }
    }
    cout << '!' << ' ' << a << ' ' << b << endl;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>

#define memc(a, x) memset(a,x,sizeof(a))
#define ll long long
#define irp(i, a, b) for(int i=a;i<b;i++)
#define drp(i, a, b) for(int i=a;i>b;i--)

using namespace std;

int main() {
//    freopen("input.txt", "r", stdin);
    int a = 0, b = 0;
    int init;
    cout << '?' << ' ' << 0 << ' ' << 0 << endl;
    cin >> init;
    drp(i, 29, -1) {

        int x1, x2;
        cout << '?' << ' ' << (a | (1 << i)) << ' ' << b << endl;
        cin >> x1;
        cout << '?' << ' ' << a << ' ' << (b | (1 << i)) << endl;
        cin >> x2;
        if (x1 == x2) {
            if (init == 1) {
                a |= 1 << i;
            }
            else if (init == -1) {
                b |= 1 << i;
            }
            init = x1;
        }
        else {
            if (init == 0) {
                if (x1 == -1) {
                    a |= 1 << i;
                    b |= 1 << i;
                }
            }
            else if (init == 1 && x1 == -1) {
                a |= 1 << i;
                b |= 1 << i;
            }
            else if (init == -1 && x1 == 1) {
                a |= 1 << i;
                b |= 1 << i;
            }
        }
    }
    cout << '!' << ' ' << a << ' ' << b << endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a=0,b=0;
int main()
{
    printf("? %d %d\n",0,0);
    fflush(stdout);
    int pre;
    scanf("%d",&pre);
    for(int i=29;i>=0;i--)
    {
        printf("? %d %d\n",1<<i,1<<i);
        fflush(stdout);
        int now;
        scanf("%d",&now);
        if(now==pre||pre==0||now==0)
        {
            if(now>0)
            {
                printf("? %d %d\n",1<<i,0);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s<0)a|=1<<i,b|=1<<i;
            }
            else
            {
                printf("? %d %d\n",0,1<<i);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s>0)a|=1<<i,b|=1<<i;
            }
        }
        else
        {
            if(now>0)b|=1<<i;
            else a|=1<<i;
        }
        pre=now;
    }
    printf("! %d %d",a,b);
    fflush(stdout);
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a=0,b=0;
int main()
{
    printf("? %d %d\n",0,0);
    fflush(stdout);
    int pre;
    scanf("%d",&pre);
    for(int i=30;i>=0;i--)
    {
        printf("? %d %d\n",1<<i,1<<i);
        fflush(stdout);
        int now;
        scanf("%d",&now);
        if(now==pre||pre==0||now==0)
        {
            if(now>0)
            {
                printf("? %d %d\n",1<<i,0);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s<0)a|=1<<i,b|=1<<i;
            }
            else
            {
                printf("? %d %d\n",0,1<<i);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s>0)a|=1<<i,b|=1<<i;
            }
        }
        else
        {
            if(now>0)b|=1<<i;
            else a|=1<<i;
        }
        pre=now;
    }
    printf("! %d %d",a,b);
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a=0,b=0;
int main()
{
    int pre=0;
    for(int i=30;i>=0;i--)
    {
        printf("? %d %d\n",1<<i,1<<i);
        fflush(stdout);
        int now;
        scanf("%d",&now);
        if(now==pre||pre==0||now==0)
        {
            if(now>0)
            {
                printf("? %d %d\n",1<<i,0);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s<0)a|=1<<i,b|=1<<i;
            }
            else
            {
                printf("? %d %d\n",0,1<<i);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s>0)a|=1<<i,b|=1<<i;
            }
        }
        else
        {
            if(now>0)b|=1<<i;
            else a|=1<<i;
        }
        pre=now;
    }
    printf("! %d %d",a,b);
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a=0,b=0;
int main()
{
    printf("? %d %d\n",0,0);
    fflush(stdout);
    int pre;
    scanf("%d",&pre);
    for(int i=29;i>=0;i--)
    {
        printf("? %d %d\n",a|1<<i,b|1<<i);
        fflush(stdout);
        int now;
        scanf("%d",&now);
        if(now==pre||pre==0||now==0)
        {
            if(now>0)
            {
                printf("? %d %d\n",a|1<<i,b);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s<0)a|=1<<i,b|=1<<i;
            }
            else
            {
                printf("? %d %d\n",a|0,b|1<<i);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s>0)a|=1<<i,b|=1<<i;
            }
            pre=now;
        }
        else
        {
            if(now>0)b|=1<<i;
            else a|=1<<i;
            printf("? %d %d\n",a,b);
            fflush(stdout);
            int s;scanf("%d",&s);
            pre=s;
        }

    }
    printf("! %d %d",a,b);
    fflush(stdout);
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a=0,b=0;
int main()
{
    printf("? %d %d\n",0,0);
    fflush(stdout);
    int pre;
    scanf("%d",&pre);
    for(int i=29;i>=0;i--)
    {
        printf("? %d %d\n",1<<i,1<<i);
        fflush(stdout);
        int now;
        scanf("%d",&now);
        if(now==pre||pre==0||now==0)
        {
            if(now>0)
            {
                printf("? %d %d\n",1<<i,0);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s<0)a|=1<<i,b|=1<<i;
            }
            else
            {
                printf("? %d %d\n",0,1<<i);
                fflush(stdout);
                int s;scanf("%d",&s);
                if(s>0)a|=1<<i,b|=1<<i;
            }
        }
        else
        {
            if(now>0)b|=1<<i;
            else a|=1<<i;
        }
        pre=now;
    }
    printf("! %d %d",a,b);
}


#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<ll,ll>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 1e2 + 2;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

int a[2], o, f, s, p;
int main()
{
    TIME;
    cout << "0 0" << endl;
    cin >> o;
    if( o == -1 )
        p = 1;
    else
        p = 0;
    for( int i = 29; i >= 0; i -- )
    {
        a[p] += (1 << i);
        cout << a[0] << " " << a[1] << endl;
        cin >> f;
        a[p] -= (1 << i);
        cout << a[0] + (1 << i) << " " << a[1] + (1 << i) << endl;
        cin >> s;
        if( f == 0 )
            a[p] += (1 << i);
        if( f == o && s == -o )
            a[p] += (1 << i);
        if( f == -o && s == 0 )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == o )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == -o )
            a[p] += (1 << i), p = (1 - p);
    }
    cout << "! " << a[0] << " " << a[1] << endl;
}


#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<ll,ll>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 1e2 + 2;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

int a[2], o, f, s, p;
int main()
{
    TIME;
    cout << "? 0 0" << endl;
    cin >> o;
    if( o == -1 )
        p = 1;
    else
        p = 0;
    for( int i = 29; i >= 0; i -- )
    {
        a[p] += (1 << i);
        cout << "? " << a[0] << " " << a[1] << endl;
        cin >> f;
        a[p] -= (1 << i);
        cout << "? " << a[0] + (1 << i) << " " << a[1] + (1 << i) << endl;
        cin >> s;
        if( f == 0 )
            a[p] += (1 << i);
        if( f == o && s == -o )
            a[p] += (1 << i);
        if( f == -o && s == 0 )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == o )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == -o )
            a[p] += (1 << i), p = (1 - p), o = -o;
    }
    cout << "! " << a[0] << " " << a[1] << endl;
}


#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<ll,ll>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 1e2 + 2;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

int a[2], o, f, s, p, x, y;
int main()
{
    TIME;
    cin >> x >> y;
    cout << "? 0 0" << endl;
    cin >> o;
    if( o == -1 )
        p = 1;
    else
        p = 0;
    for( int i = 4; i >= 0; i -- )
    {
        a[p] += (1 << i);
        cout << "? " << a[0] << " " << a[1] << endl;
        cin >> f;
        a[p] -= (1 << i);
        cout << "? " << a[0] + (1 << i) << " " << a[1] + (1 << i) << endl;
        cin >> s;
        if( f == 0 )
            a[p] += (1 << i);
        if( f == o && s == -o )
            a[p] += (1 << i);
        if( f == -o && s == 0 )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == o )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == -o )
            a[p] += (1 << i), p = (1 - p), o = -o;
    }
    cout << "! " << a[0] << " " << a[1] << endl;
}


#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<ll,ll>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 1e2 + 2;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

int a[2], o, f, s, p;
int main()
{
    TIME;
    cout << "? 0 0" << endl;
    cin >> o;
    if( o == 0 )
        o = 1;
    if( o == -1 )
        p = 1;
    for( int i = 4; i >= 0; i -- )
    {
        a[p] += (1 << i);
        cout << "? " << a[0] << " " << a[1] << endl;
        cin >> f;
        a[p] -= (1 << i);
        cout << "? " << a[0] + (1 << i) << " " << a[1] + (1 << i) << endl;
        cin >> s;
        if( f == 0 )
            a[p] += (1 << i);
        if( f == o && s == -o )
            a[p] += (1 << i);
        if( f == -o && s == 0 )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == o )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == -o )
            a[p] += (1 << i), p = (1 - p), o = -o;
    }
    cout << "! " << a[0] << " " << a[1] << endl;
}


#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<ll,ll>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 1e2 + 2;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

int a[2], o, f, s, p, x, y;
int main()
{
    TIME;
    cin >> x >> y;
    cout << "? 0 0" << endl;
    cout << o << endl;
    if( o == -1 )
        p = 1;
    else
        p = 0;
    for( int i = 4; i >= 0; i -- )
    {
        a[p] += (1 << i);
        cout << "? " << a[0] << " " << a[1] << endl;
        cin >> f;
        a[p] -= (1 << i);
        cout << "? " << a[0] + (1 << i) << " " << a[1] + (1 << i) << endl;
        cin >> s;
        if( f == 0 )
            a[p] += (1 << i);
        if( f == o && s == -o )
            a[p] += (1 << i);
        if( f == -o && s == 0 )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == o )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == -o )
            a[p] += (1 << i), p = (1 - p), o = -o;
    }
    cout << "! " << a[0] << " " << a[1] << endl;
}


#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<ll,ll>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 1e2 + 2;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

int a[2], o, f, s, p, x, y;
int main()
{
    TIME;
    cin >> x >> y;
    cout << "? 0 0" << endl;
    func( o, 0, 0 );
    cout << o << endl;
    if( o == -1 )
        p = 1;
    else
        p = 0;
    for( int i = 29; i >= 0; i -- )
    {
        a[p] += (1 << i);
        cout << "? " << a[0] << " " << a[1] << endl;
        cin >> f;
        a[p] -= (1 << i);
        cout << "? " << a[0] + (1 << i) << " " << a[1] + (1 << i) << endl;
        cin >> s;
        if( f == 0 )
            a[p] += (1 << i);
        if( f == o && s == -o )
            a[p] += (1 << i);
        if( f == -o && s == 0 )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == o )
            a[0] += (1 << i), a[1] += (1 << i);
        if( f == -o && s == -o )
            a[p] += (1 << i), p = (1 - p), o = -o;
    }
    cout << "! " << a[0] << " " << a[1] << endl;
}