#include <bits/stdc++.h>
using namespace std;
const int N = 1000, MD = 1000000007;
char aa[N + 1], bb[N + 1], cc[N * 3];
int zz[N * 3], qu[N], dp[N], dq[N + N];
int main() {
  int k;
  cin >> aa >> bb >> k;
  int n = strlen(aa);
  for (int i = 0; i < n; i++) {
    cc[i] = bb[i];
    cc[n + i] = cc[n + n + i] = aa[i];
  }
  for (int l = 0, r = 0, i = 1; i < n * 3; i++)
    if (i + zz[i - l] < r)
      zz[i] = zz[i - l];
    else {
      l = i;
      if (r < l) r = l;
      while (r < n * 3 && cc[r] == cc[r - l]) r++;
      zz[i] = r - l;
    }
  int cnt = 0;
  for (int i = n; i < n + n; i++)
    if (zz[i] >= n) qu[cnt++] = i - n;
  if (cnt == 0) {
    cout << "0\n";
    return 0;
  }
  dp[0] = 1;
  while (k--) {
    long long sum = 0;
    for (int i = 0; i < n; i++) sum += dp[i];
    for (int i = 0; i < n; i++) dp[i] = (sum - dp[i]) % MD;
  }
  int ans = 0;
  for (int h = 0; h < cnt; h++) {
    int i = qu[h];
    ans = (ans + dp[i]) % MD;
  }
  cout << ans << '\n';
  return 0;
}
