#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int n,p,q;
char x[2005],y[2005];
char f[2005][6];
int ex[2005];
ll dp[2005];
ll dp2[2005][2005];
int c[2005][2005];
vector<int>num;
ll rec(int i,int j)
{
if(dp2[i][j]>=0) return dp2[i][j];
if(j==0) return dp2[i][j] = 1;
if(i>=num.size()) return dp2[i][j] = 0;
return dp2[i][j] = (1LL*num[i]*rec(i+1,j-1) + rec(i+1,j)) %mod;
}
int main()
{
scanf("%d %d %d",&n,&p,&q);
for(int i=0;i<n;i++) scanf(" %c",&x[i]);
for(int i=0;i<n;i++) scanf(" %c",&y[i]);
for(int i=0;i<n;i++) scanf("%s",&f[i]);
for(int i=0;i<n;i++) for(int j=0;j<5;j++) ex[i]+=(f[i][j]!='.');
dp[0]=1;
for(int i=0;i<n;i++)
{
if(x[i] == y[i])
{
for(int j=2003;j>=0;j--)
{
dp[j] = (dp[j]*(ex[i]-1)+(j?dp[j-1]:0))%mod;
}
}
else
{
num.push_back(ex[i]-2);
}
}
memset(dp2,-1,sizeof(dp2));
for(int i=0;i<num.size();i++)
{
for(int j=0;j<=n;j++)
{
if(dp2[i][j] >= 0) continue;
dp2[i][j] = rec(i,j);
}
}
for(int i=0;i<=2000;i++)
{
for(int j=0;j<=i;j++)
{
if(j==0 || j==i) c[i][j]=1;
else c[i][j] = (c[i-1][j-1]+c[i-1][j])%mod;
}
}
ll res = 0;
for(int i=0;i<=min(p,q);i++)
{
int pp = p-i;
int qq = q-i;
int ot = num.size()-pp-qq;
if(ot<0) continue;
res = (res+(dp2[0][ot]*dp[i])%mod*c[pp+qq][pp])%mod;
}
printf("%lld\n",res);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKIAppbnQgbixwLHE7CmNoYXIgeFsyMDA1XSx5WzIwMDVd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