#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<iostream>
#include<string>
#include<cmath>
#define inf 1e17
#define N 100010
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
typedef long long LL;
using namespace std;
int len=1;
LL ca[N],p[N];char s[N];
int e[N],last[N],pre[N],dis[3010],gap[3010],source,target,NC,n,m,k,a[N];
void add(int x,int y,LL CA)
{
pre[++len]=last[x];last[x]=len;e[len]=y;ca[len]=CA;
pre[++len]=last[y];last[y]=len;e[len]=x;ca[len]=0;
}
LL aug(int u,LL m)
{
if (u==target) return m;
LL f=m;int td=NC;
for(int p=last[u];p;p=pre[p])
if (ca[p]>0)
{
int v=e[p];
if (dis[u]==dis[v]+1)
{
LL tmp=aug(v,min(f,ca[p]));
ca[p]-=tmp,ca[p^1]+=tmp,f-=tmp;
if (!f||dis[source]==NC) return m-f;
}
td=min(td,dis[v]+1);
}
if (f==m)
{
if (!--gap[dis[u]]) dis[source]=NC;
gap[dis[u]=td]++;
}
return m-f;
}
LL sap()
{
memset(gap,0,sizeof(gap));
memset(dis,0,sizeof(dis));
LL ans=0;gap[0]=NC;
while(dis[source]<NC)ans+=aug(source,inf);
return ans;
}
int calc(char c)
{
if (c=='/') return 0;
if (c=='+') return 1;
return -1;
}
int main()
{
scanf("%d%d%d",&n,&m,&k);
p[k]=1;int i,j;
ROF(i,k-1,1) p[i]=p[i+1]*2001;
LL sum=0;
FOR(i,1,k) sum=sum*2001+1000;
source=n+1;NC=target=n+2;
FOR(i,1,n)
{
scanf("%s",s+1);
LL tmp=0;
FOR(j,1,k) tmp+=p[j]*calc(s[j]);
if (tmp>=0) {add(source,i,tmp);sum+=tmp;}
else add(i,target,-tmp);
}
FOR(i,1,m)
{
int x,y;
scanf("%d%d",&x,&y);
add(x,y,inf);
}
LL ans=sum-sap();
ROF(i,k,1) {a[i]=ans%2001;ans/=2001;}
FOR(i,1,k-1) printf("%d ",a[i]);
printf("%d\n",a[k]);
}