#include <bits/stdc++.h>
using namespace std;
int l[4002];
int posl(string s) {
  l[0] = -1;
  for (int k = 1; k < s.size(); k++) {
    int j = l[k - 1];
    while (j >= 0 && s[j + 1] != s[k]) {
      j = l[j];
    }
    if (j == -1 && s[k] != s[0]) j--;
    l[k] = j + 1;
  }
  return l[s.size() - 1] + 1;
}
int main() {
  string a, b;
  cin >> a >> b;
  string news;
  news = b + b + '$' + a + a;
  int k = posl(a);
  int per = -1;
  if (2 * k >= a.size()) per = (int)a.size() - k;
  int pp = posl(news);
  pp = 2 * (int)a.size() - pp;
  if (pp >= a.size()) {
    cout << "0" << endl;
    return 0;
  }
  vector<int> pa;
  int l = pp;
  pa.push_back(l);
  l += per;
  while (l < a.size() && per != -1) {
    pa.push_back(l);
    l += per;
  }
  cin >> k;
  int c[1001][2];
  int sum = 1;
  c[0][0] = 1;
  for (int j = 1; j < a.size(); j++) {
    c[j][0] = 0;
  }
  for (int i = 1; i <= k; i++) {
    long long newsum = 0;
    int ii = i % 2;
    for (int j = 0; j < a.size(); j++) {
      c[j][ii] = (sum - c[j][1 - ii]);
      if (c[j][ii] < 0) c[j][ii] += +1000000007;
      newsum += c[j][ii];
    }
    newsum %= 1000000007;
    sum = (int)newsum;
  }
  int ans = 0;
  for (int i = 0; i < pa.size(); i++) {
    ans += c[pa[i]][k % 2];
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
