#include<cstdio>
#include<cctype>
#include<queue>
#include<cstring>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define ren for(int i=first[x];i;i=next[i])
using namespace std;
inline int read() {
int x=0,f=1;char c=getchar();
for(;!isdigit(c);c=getchar()) if(c==‘-‘) f=-1;
for(;isdigit(c);c=getchar()) x=x*10+c-‘0‘;
return x*f;
}
typedef long long ll;
const int mod=1000000007;
int f[25][35][35][2];//f[x][t][v] ‘(‘ - ‘)‘
int n,k,m,e[25][25];
char s[25];
int iscal(char c) {return c==‘+‘||c==‘-‘||c==‘*‘||c==‘/‘;}
int dp(int x,int t,int c,int pre) {
if(t>=k) return (!c)&&!iscal(s[x]);
int& ans=f[x][t][c][pre];
if(ans>=0) return ans;
ans=0;
rep(i,1,n) if(e[x][i]) {
if(s[i]>=‘0‘&&s[i]<=‘9‘) {
if(s[x]>=‘0‘&&s[x]<=‘9‘) {
if(!pre) (ans+=dp(i,t+1,c,0))%=mod;
}
else if(iscal(s[x])||s[x]==‘(‘) (ans+=dp(i,t+1,c,s[i]==‘0‘))%=mod;
}
else if(s[i]==‘(‘||s[i]==‘)‘) {
if(s[i]==‘(‘&&(s[x]==‘(‘||iscal(s[x]))) (ans+=dp(i,t+1,c+1,0))%=mod;
else if(s[i]==‘)‘&&c&&(isdigit(s[x])||s[x]==‘)‘)) (ans+=dp(i,t+1,c-1,0))%=mod;
}
else {
if(s[x]>=‘0‘&&s[x]<=‘9‘) (ans+=dp(i,t+1,c,s[i]==‘0‘))%=mod;
if(s[x]==‘)‘) (ans+=dp(i,t+1,c,0))%=mod;
if(s[x]==‘(‘&&s[i]==‘-‘) (ans+=dp(i,t+1,c,0))%=mod;
}
}
return ans;
}
int main() {
memset(f,-1,sizeof(f));
n=read();m=read();k=read();
scanf("%s",s+1);
rep(i,1,m) {
int x=read(),y=read();
e[x][y]=e[y][x]=1;
}
int ans=0;
rep(i,1,n) {
if(s[i]==‘(‘) (ans+=dp(i,1,1,0))%=mod;
if(s[i]==‘-‘) (ans+=dp(i,1,0,0))%=mod;
if(s[i]>=‘1‘&&s[i]<=‘9‘) (ans+=dp(i,1,0,0))%=mod;
if(s[i]==‘0‘) (ans+=dp(i,1,0,1))%=mod;
}
printf("%d\n",ans);
return 0;
}