#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ()
{
ll n, k, x, i, j, l, cnt=0, cnt1=0, cnt2=0, cnt3=0, num=0;
cin >> n >> k;
x=n/k;
double power=pow(10.0, (double)k);
ll p=power;
power=pow(10.0, (double)(k-1));
ll q=power;
//cout << p;
ll a[x], b[x], c[x];
for (i=0; i<x; i++) cin >> a[i];
for (i=0; i<x; i++) cin >> b[i];
if (n==1 && a[0]==1)
{
cout << 9;
return 0;
}
for (i=0; i<x; i++)
{
cnt=0;
//j=1;
num=a[i];
ll h=num;
cnt1=(p-1)/a[i];
if (b[i]==0)
{
//cout << q-1 << endl;
cnt2=(q-1)/a[i];
}
else
{
cnt2=((b[i]+1)*q-1)/a[i]-(b[i]*q-1)/a[i];
}
//cout << cnt1 << " " << cnt2;
cnt=cnt1-cnt2;
//int o=num;
/*while(h/10!=0)
{
h/=10;
}*/
//h/=q;
//if (h!=b[i]) cnt++;
//cout << h << endl;
//j++;
//num=a[i]*j;
//cout << num << endl;
if (b[i]==0) c[i]=cnt;
else c[i]=cnt+1;
}
/*for (i=0; i<x; i++)
{
cout << a[i] << " ";
}
for (i=0; i<x; i++)
{
cout << b[i] << " ";
}*/
/*for (i=0; i<x; i++)
{
cout << c[i] << " ";
}*/
ll ans=1;
for (i=0; i<x; i++)
{
ll r=c[i];
ans=ans*r;
ans=ans%1000000007;
//cout << ans << endl;
}
cout << ans;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmludCBtYWluICgpCnsKICAgIGxsIG4sIGssIHgsIGksIGosIGwsIGNudD0wLCBjbnQxPTAsIGNudDI9MCwgY250Mz0wLCBudW09MDsKICAgIGNpbiA+PiBuID4+IGs7CiAgICB4PW4vazsKICAgIGRvdWJsZSBwb3dlcj1wb3coMTAuMCwgKGRvdWJsZSlrKTsKICAgIGxsIHA9cG93ZXI7CiAgICBwb3dlcj1wb3coMTAuMCwgKGRvdWJsZSkoay0xKSk7CiAgICBsbCBxPXBvd2VyOwogICAgLy9jb3V0IDw8IHA7CiAgICBsbCBhW3hdLCBiW3hdLCBjW3hdOwogICAgZm9yIChpPTA7IGk8eDsgaSsrKSBjaW4gPj4gYVtpXTsKICAgIGZvciAoaT0wOyBpPHg7IGkrKykgY2luID4+IGJbaV07CiAgICBpZiAobj09MSAmJiBhWzBdPT0xKQogICAgewogICAgICAgIGNvdXQgPDwgOTsKICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIGZvciAoaT0wOyBpPHg7IGkrKykKICAgIHsKICAgICAgICBjbnQ9MDsKICAgICAgICAvL2o9MTsKICAgICAgICBudW09YVtpXTsKICAgICAgICBsbCBoPW51bTsKICAgICAgICBjbnQxPShwLTEpL2FbaV07CiAgICAgICAgaWYgKGJbaV09PTApCiAgICAgICAgewogICAgICAgICAgICAvL2NvdXQgPDwgcS0xIDw8IGVuZGw7CiAgICAgICAgICAgIGNudDI9KHEtMSkvYVtpXTsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgY250Mj0oKGJbaV0rMSkqcS0xKS9hW2ldLShiW2ldKnEtMSkvYVtpXTsKICAgICAgICB9CiAgICAgICAgLy9jb3V0IDw8IGNudDEgPDwgIiAiIDw8IGNudDI7CiAgICAgICAgY250PWNudDEtY250MjsKICAgICAgICAvL2ludCBvPW51bTsKICAgICAgICAvKndoaWxlKGgvMTAhPTApCiAgICAgICAgewogICAgICAgICAgICBoLz0xMDsKICAgICAgICB9Ki8KICAgICAgICAvL2gvPXE7CiAgICAgICAgLy9pZiAoaCE9YltpXSkgY250Kys7CiAgICAgICAgLy9jb3V0IDw8IGggPDwgZW5kbDsKICAgICAgICAvL2orKzsKICAgICAgICAvL251bT1hW2ldKmo7CiAgICAgICAgLy9jb3V0IDw8IG51bSA8PCBlbmRsOwogICAgICAgIGlmIChiW2ldPT0wKSBjW2ldPWNudDsKICAgICAgICBlbHNlIGNbaV09Y250KzE7CiAgICB9CiAgICAvKmZvciAoaT0wOyBpPHg7IGkrKykKICAgIHsKICAgICAgICBjb3V0IDw8IGFbaV0gPDwgIiAiOwogICAgfQogICAgZm9yIChpPTA7IGk8eDsgaSsrKQogICAgewogICAgICAgIGNvdXQgPDwgYltpXSA8PCAiICI7CiAgICB9Ki8KICAgIC8qZm9yIChpPTA7IGk8eDsgaSsrKQogICAgewogICAgICAgIGNvdXQgPDwgY1tpXSA8PCAiICI7CiAgICB9Ki8KICAgIGxsIGFucz0xOwogICAgZm9yIChpPTA7IGk8eDsgaSsrKQogICAgewogICAgICAgIGxsIHI9Y1tpXTsKICAgICAgICBhbnM9YW5zKnI7CiAgICAgICAgYW5zPWFucyUxMDAwMDAwMDA3OwogICAgICAgIC8vY291dCA8PCBhbnMgPDwgZW5kbDsKICAgIH0KICAgIGNvdXQgPDwgYW5zOwogICAgcmV0dXJuIDA7Cn0=