#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)
#define hmap gp_hash_table<ll, ll>

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

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

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
    a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}
 
ll norm(ll a)
{
    a%=mod;
    if(a<0)
        a+=mod;
    return a;    
}
 
ll add(ll a, ll b)
{
    a = norm(a);
    b = norm(b);
    return norm(a+b);
}
 
ll mul(ll a, ll b)
{
    a = norm(a);
    b = norm(b);
    return norm(a*b);
}
 
 
ll sub(ll a, ll b)
{
    a = norm(a);
    b = norm(b);
    return norm(a-b);
}
 
ll divi(ll a, ll b)
{
    b = powa(b,mod-2,mod);
    return mul(a,b);
}

#define N 105

void mul(ll res[N][N], ll m1[N][N], ll m2[N][N])
{
    ll temp[N][N];
    memset(temp,0,sizeof(temp));
    for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            for(ll k=0;k<N;k++)
            {
                temp[i][j]+=(m1[i][k]*m2[k][j])%mod;
                temp[i][j]%=mod;
            }
    for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            res[i][j] = temp[i][j];
                
}

void powam(ll mat[N][N], ll n)
{
   ll res[N][N];
   memset(res,0,sizeof(res));
   for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            if(i == j)
                res[i][j] = 1;
   
   while(n>0)
   {
       if(n%2 == 1)
           mul(res,res,mat);
       
       n>>=1;
       mul(mat,mat,mat);
   }
   
   for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            mat[i][j] = res[i][j];
    
}

int main()
{
  FAST/**/
  
  ll n,m,k;
  cin>>n>>m>>k;
  
  ll arr[n];
  rep(n)
        cin>>arr[i];
  ll mat[N][N];
  memset(mat,0,sizeof(mat));
  
  ll adj[N][N];
  memset(adj,0,sizeof(adj));
  
  vector<ll> gr(n,0);
  
  ll i2 = powa(2,mod-2,mod);
  
  rep(m)
  {
      ll x,y;
      cin>>x>>y;
      x--, y--;
      gr[x]++;
      gr[y]++;
      adj[x][y] = adj[y][x] = 1;
  }
  
  rep(n)
        repi(j,n)
        {
            if(i == j)
                mat[i][j] = sub(m, mul(1,mul(gr[i],i2)));
            else if(adj[i][j])
                mat[i][j] = i2;
        }
  powam(mat,k);
  ll fac = powa(powa(m,mod-2,mod),k,mod);
  ll ans[n];
  memset(ans,0,sizeof(ans));
  rep(n)
  {
      repi(j,n)
            ans[i] = add(ans[i], mul(mat[i][j], arr[j]));
      ans[i] = mul(ans[i], fac);    
      cout<<ans[i]<<'\n';
  }
  
  
    
  return 0;
}
   
   
 
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define pb emplace_back
#define lb(v,k) (lower_bound(all(v),(k))-v.begin())
#define ub(v,k) (upper_bound(all(v),(k))-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void outset(T s){auto itr=s.begin();while(itr!=s.end()){if(itr!=s.begin())cout<<' ';cout<<*itr;itr++;}cout<<'\n';}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    string s,t;cin>>s>>t;
    vi a,b;
    rep(i,n){
        if(s[i]=='0')a.pb(i);
        if(t[i]=='0')b.pb(i);
    }
    if(a.size()!=b.size())dame(-1);
    ll ans=0;
    rep(i,a.size())if(a[i]!=b[i])ans++;
    out(ans);
}