#include <bits/stdc++.h>

const long long INF = 1e9;
const long long MOD = 1e9 + 7;
//const long long MOD = 998244353;
const long long LINF = 1e18;
using namespace std;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define COUT(x) cout<<(x)<<endl
#define SCOUT(x) cout<<(x)<<" "
#define VECCOUT(x) for(auto&youso_: (x) )cout<<right<<setw(10)<<youso_<<" ";cout<<endl
#define ENDL cout<<endl
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) long long __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define mp make_pair
#define PQ priority_queue<long long>
#define PQG priority_queue<long long,V,greater<long long>>


typedef long long ll;
typedef vector<long long> vl;
typedef vector<long long> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef pair<long long, long long> pll;


#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
template<class T>
void mod(T &x) {
    x %= MOD;
    x += MOD;
    x %= MOD;
}

ll GCD(ll a, ll b) {
    if(b == 0) return a;
    else return GCD(b, a%b);
}

struct COMB{
    vl fact, fact_inv, inv;
    void init_nCk(long long SIZE) {
        fact.resize(SIZE + 5);
        fact_inv.resize(SIZE + 5);
        inv.resize(SIZE + 5);
        fact.at(0) = fact.at(1) = fact_inv.at(0) = fact_inv.at(1) = inv.at(1) = 1;
        for(long long i = 2; i < SIZE + 5; i++) {
            fact.at(i) = fact.at(i - 1)*i%MOD;
            inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
            fact_inv.at(i) = fact_inv.at(i - 1)*inv.at(i)%MOD;
        }
    }
    long long nCk (long long n, long long k) {
        assert(!(n < k));
        assert(!(n < 0 || k < 0));
        return fact.at(n)*(fact_inv.at(k)*fact_inv.at(n - k)%MOD)%MOD;
    }
};
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}


void Main() {
    LCIN(H, W, X, Y);
    vvl m(H, vl(W, 0));
    for(int i = 0; i < H; i++) {
        SCIN(S);
        for(int j = 0; j < W; j++) {
            m.at(i).at(j) = S.at(j) == '#';
        }
    }
    --X;
    --Y;
    ll ans = -3;
    for(int i = X; i < H; i++) {
        if(m.at(i).at(Y))break;
        ++ans;
    }
    for(int i = X; i >= 0; i--) {
        if(m.at(i).at(Y))break;
        ++ans;
    }
    for(int i = Y; i < W; i++) {
        if(m.at(X).at(i))break;
        ++ans;
    }
    for(int i = Y; i >= 0; i--) {
        if(m.at(X).at(i))break;
        ++ans;
    }
    cout << ans << endl;
}

int main() {
    cout << fixed << setprecision(15);
    Main();
    return 0;
}
/*
 * Author - Abhas Jain
 * Code is inside the solve function
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
struct Matrix {
    vector<vector<ll>> data;
    // for small n,m array should be used.
    int n, m;

    Matrix(int n, int m) : data(n, vector<ll>(m)), n(n), m(m) {}
    Matrix(vector<vector<ll>> g) : data(g) {
        n = g.size();
        m = g[0].size();
    }

    Matrix mult(const Matrix&rhs) const {
        int n = (*this).n;
        int m = rhs.m;
        int tmp = rhs.n;
        Matrix ans(n, m);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < tmp; ++j) {
                for (int k = 0; k < m; ++k) {
                    ans.data[i][k] = (ans.data[i][k] + data[i][j] * rhs.data[j][k]) % mod;
                }
            }
        }
        return ans;
    }
 
    Matrix pow(ll pw) const {
        int sz = (*this).n;
        Matrix ans(sz, sz);
        Matrix exp = *this;
        for (int i = 0; i < sz; ++i) { ans.data[i][i] = 1; }
        while (pw) {
          if (pw & 1) { ans = ans.mult(exp); }
          pw >>= 1;
          exp = exp.mult(exp);
        }
        return ans;
    }
};


ll modinv(ll x) {
    ll ans = 1, ex = mod - 2;
    while (ex > 0) {
        if (ex & 1ll) {
            ans = (ans * x) % mod;
        }
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

void solve() 
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    Matrix tr(n, n);
    vector<int> deg(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        tr.data[a][b] = 1;
        tr.data[b][a] = 1;
    }
    ll div = modinv(2 * m);
    for (int i = 0; i < n; ++i) {
        tr.data[i][i] = 2 * m - deg[i];
        tr.data[i][i] %= mod;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            tr.data[i][j] *= div;
            tr.data[i][j] %= mod;
        }
    }
    //debug(tr.data);
    tr = tr.pow(k);
    //debug(tr.data);
    for (int i = 0; i < n; ++i) {
        ll cur = 0;
        for (int j = 0; j < n; ++j) {
            cur += a[j] * tr.data[j][i];
            cur %= mod; 
        }
        cout << cur << endl;
    }
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}